Python Forum
How to ignore - ERROR: The system was unable to find the specified registry key or va - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to ignore - ERROR: The system was unable to find the specified registry key or va (/thread-15810.html)



How to ignore - ERROR: The system was unable to find the specified registry key or va - asheru93 - Feb-01-2019

def isAlreadyInstalled(lookupRegistryKey):
    consoleLines = os.popen('reg query "' + APP_REGISTRY_KEY + "\\" + VERSION_SYSTEM_NAME + '"').readlines()
    if len(consoleLines) == 0:
        return False
    return True
I have this snippet. The problem is that it gives this error in the command line without stoping the execution ( wich is ok for my cas), I just want to ignore this error.

ERROR: The system was unable to find the specified registry key or value.


RE: How to ignore - ERROR: The system was unable to find the specified registry key or va - DreamingInsanity - Feb-01-2019

Does it also error in python?


RE: How to ignore - ERROR: The system was unable to find the specified registry key or va - asheru93 - Feb-01-2019

No, my script is working ok. But this just pops there and i don't want to see it.

I'm looping for 5 minutes, call this method evrey second to check if a program is installed or not. I want to ignore this if possible somehow here inside the method


RE: How to ignore - ERROR: The system was unable to find the specified registry key or va - Larz60+ - Feb-01-2019

use try/except block, with the except capturing the specific error
and content of except 'pass'


RE: How to ignore - ERROR: The system was unable to find the specified registry key or va - asheru93 - Feb-01-2019

  
 def isAlreadyInstalled(lookupRegistryKey):
        try:
            consoleLines = os.popen('reg query "' + APP_REGISTRY_KEY + "\\" + VERSION_SYSTEM_NAME + '"').readlines()
            if len(consoleLines) == 0:
                return False
            return True
        except OSError:
            pass
This is not working.


RE: How to ignore - ERROR: The system was unable to find the specified registry key or va - Larz60+ - Feb-01-2019

you haven't shown the error message.
Post that verbatim please


RE: How to ignore - ERROR: The system was unable to find the specified registry key or va - asheru93 - Feb-01-2019

This is the error shown in the command line:

ERROR: The system was unable to find the specified registry key or value.



RE: How to ignore - ERROR: The system was unable to find the specified registry key or va - Larz60+ - Feb-01-2019

This error does not look like a python generated error traceback as it is incomplete.
if that's all you have, then you need to show more code, especially the 'lookupRegistryKey'
method or function (or package name if in a package). Soesn't loog like a winreg error either.

Can't help with information provided.


RE: How to ignore - ERROR: The system was unable to find the specified registry key or va - ichabod801 - Feb-01-2019

If it's not stopping the execution of the program, it's not an error from Python's perspective. A try/except block certainly won't work. I don't know if there is anything you can do in Python to stop it. Is there perhaps an option to the system command you are using that would suppress the error output?


RE: How to ignore - ERROR: The system was unable to find the specified registry key or va - asheru93 - Feb-04-2019

APP_REGISTRY_KEY - HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
lookupRegistryKey = theNameOfTheApplication

@ichabod801 - there is but in this case my condition( if len(consoleLines) == 0: ) will always be false since.