View Single Post
Old 07-04-2019, 11:59 AM   #2
DaltonST
Deviser
DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.
 
DaltonST's Avatar
 
Posts: 2,265
Karma: 2090983
Join Date: Aug 2013
Location: Texas
Device: none
WindowsError: [Error 740] The requested operation requires elevation

I ran Calibre 3.44 from source after making some changes to auto_add.py:


Code:
    def auto_add(self):
        from calibre.utils.ipc.simple_worker import fork_job, WorkerError
        from calibre.ebooks.metadata.opf2 import metadata_to_opf
        from calibre.ebooks.metadata.meta import metadata_from_filename

        files = [x for x in os.listdir(self.path) if
                    # Must not be in the process of being added to the db
                    x not in self.staging and
                    # Firefox creates 0 byte placeholder files when downloading
                    os.stat(os.path.join(self.path, x)).st_size > 0 and
                    # Must be a file
                    os.path.isfile(os.path.join(self.path, x)) and
                    # Must have read and write permissions
                    os.access(os.path.join(self.path, x), os.R_OK|os.W_OK) and
                    # Must be a known ebook file type
                    self.is_filename_allowed(x)
                ]
        #~ ===========================================================

        #~ zzzzzzzzzzzz RESULTS USING ORIGINAL zzzzzzzzzzzzzzzzzzzzzzzzzz
        if DEBUG:
            n = len(files)
            print("zzzzzzzzzzzzzzzzzzzz   ORIGINAL:  Number of files in os.listdir accepted: ", bytes(n))
            for f in files:
                print("zzzzzzzzzzzzzzzzzzzz   os.listdir: ", f)
        #~ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz

        files = [x for x in os.listdir(self.path) if
                    # Must not be in the process of being added to the db
                    x not in self.staging and
                    # Firefox creates 0 byte placeholder files when downloading
                    os.stat(os.path.join(self.path, x)).st_size > 0 and
                    # Must be a file
                    os.path.isfile(os.path.join(self.path, x)) and
                                        # Must have read and write permissions
                                        #~ os.access(os.path.join(self.path, x), os.R_OK|os.W_OK) and  
                    # Must be a known ebook file type
                    self.is_filename_allowed(x)
                ]

        #~ zzzzzzzzzzzz RESULTS USING REVISED zzzzzzzzzzzzzzzzzzzzzzzzzz
        from calibre.constants import DEBUG
        if DEBUG:
            n = len(files)
            print("zzzzzzzzzzzzzzzzzzzz   REVISED:  Number of files in os.listdir accepted: ", bytes(n))
            for f in files:
                print("zzzzzzzzzzzzzzzzzzzz   os.listdir: ", f)
        #~ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
The debug results:

Code:
[7.28] main UI initialized...
[7.28] Hiding splash screen
Job Spy: Quality Fixes have been activated as of:  2019-07-04 15:36:00
[8.23] splash screen hidden
[8.25] Started up in 8.25 seconds with 1130 books
zzzzzzzzzzzzzzzzzzzz   ORIGINAL:  Number of files in os.listdir accepted:  0
zzzzzzzzzzzzzzzzzzzz   REVISED:  Number of files in os.listdir accepted:  2
zzzzzzzzzzzzzzzzzzzz   os.listdir:  Collapsing Empire, The - John Scalzi.epub
zzzzzzzzzzzzzzzzzzzz   os.listdir:  The Consuming Fire (The Interdependency, Book 2) by John Scalzi.epub
Traceback (most recent call last):
  File "Y:\calibre_source_v3_44_0\src\calibre\gui2\auto_add.py", line 163, in auto_add
  File "Y:\calibre_source_v3_44_0\src\calibre\utils\ipc\simple_worker.py", line 225, in fork_job
  File "Y:\calibre_source_v3_44_0\src\calibre\utils\ipc\simple_worker.py", line 139, in create_worker
  File "Y:\calibre_source_v3_44_0\src\calibre\utils\ipc\launch.py", line 237, in __call__
  File "subprocess.py", line 394, in __init__
  File "subprocess.py", line 644, in _execute_child
WindowsError: [Error 740] The requested operation requires elevation
I am the Administrator of the PC, I have UAC set to "do nothing", and I execute Calibre "As Administrator".

As previously mentioned, the problem exists even if --ignore-plugins is specified.


ADDED/CHANGED: resetting the auto-add folder permissions properties to "Full-Control" for me, Administrators, Everyone, etc. did NOT remove "Error 740", but it DID show that the ORIGINAL code was considering the epubs as being readable and writable. So,it appears that it is necessary but not sufficient that the permissions of the auto-add folder be minimal/loose.


ADDED:
This is what Microsoft says about the above UAC error shown in the attached image:

Code:
 This this is the purpose of UAC, it strips admin privileges from normally-launched processes.
This encourages you to not use dangerous admin powers where you don't need to. You may try to modify the UAC on Local Security Policy for test:
 1 Login with Administrator
  2 Type in secpol.msc into the Start menu search box and hit enter
 3 browse  down to Local Policies \ Security Options\ User Account Control:  Behavior of the elevation prompt for administrators in Admin Approval  Mode” and double-click on it.
 4 Change the setting to “Elevate without prompting”.
Great. But secpol.msc and the group policy editor, gpedit, do not exist in Windows 10 Home. I do not want to have to upgrade to Windows 10 Pro for the single purpose of setting UAC to “Elevate without prompting”.


I wonder what version of Windows 10 is Calibre auto-add tested on. Home or Pro? And what Version(s)?





DaltonST
Attached Thumbnails
Click image for larger version

Name:	event_viewer_info.jpg
Views:	194
Size:	83.5 KB
ID:	172249  

Last edited by DaltonST; 07-04-2019 at 01:14 PM. Reason: Added comment and image
DaltonST is offline   Reply With Quote