def main(): # Derek Cheng: If the user is running the uninstaller on the Nokia N800, we # require them to be on root to remove some files in /etc/init.d and # /etc/rc2.d directories. This needs to preceed servicelogger.init, since # only root has permission to installInfo. if platform.machine().startswith('armv'): # Derek Cheng: This is for detecting if the user is root. This module # isn't portable so I only can import it on Linux / Nokia devices import pwd # Check to see if the current user is root. if pwd.getpwuid(os.getuid())[0] != 'root': _output('Please run the uninstaller as root. This can be done by ' \ + 'installing/using the rootsh or openssh package.') return # Begin pre-uninstall process. # Initialize the service logger. servicelogger.init('installInfo') # Pre-uninstall: parse the passed-in arguments. try: opts, args = getopt.getopt(sys.argv[1:], "s", ["win-startup-path=","usage"]) except getopt.GetoptError, err: print str(err) usage() return
def main(): # Derek Cheng: If the user is running the uninstaller on the Nokia N800, we # require them to be on root to remove some files in /etc/init.d and # /etc/rc2.d directories. This needs to preceed servicelogger.init, since # only root has permission to installInfo. if platform.machine().startswith('armv'): # Derek Cheng: This is for detecting if the user is root. This module # isn't portable so I only can import it on Linux / Nokia devices import pwd # Check to see if the current user is root. if pwd.getpwuid(os.getuid())[0] != 'root': _output('Please run the uninstaller as root. This can be done by ' \ + 'installing/using the rootsh or openssh package.') return # Begin pre-uninstall process. # Initialize the service logger. servicelogger.init('installInfo') # Pre-uninstall: parse the passed-in arguments. try: opts, args = getopt.getopt(sys.argv[1:], "s", ["win-startup-path=", "usage"]) except getopt.GetoptError, err: print str(err) usage() return
def safe_servicelogger_init(): """ This initializes the servicelogger in a way that will not throw an exception even if servicelogger.init() does. """ # initialize the servicelogger to log on the softwareupdater file try: servicelogger.init("softwareupdater") except: # We assume that if servicelogger.init() fails, then safe_log will # fall back on using 'print' because servicelogger.log() calls # will throw a ValueError. safe_log("Servicelogger.init() failed. Will try to use stdout. The exception from servicelogger.init() was:") safe_log_last_exception()
FOREGROUND = True if options.test_mode: TEST_NM = True if __name__ == '__main__': """ Start up the nodemanager. We are going to setup the servicelogger, then parse the arguments and then start everything up. """ # Initialize the service logger. We need to do this before calling main # because we want to print exceptions in main to the service log servicelogger.init('nodemanager') # Parse the arguments passed in the command line to set # different variables. parse_arguments() # Armon: Add some logging in case there is an uncaught exception try: main() except Exception,e: # If the servicelogger is not yet initialized, this will not be logged. servicelogger.log_last_exception() # Since the main thread has died, this is a fatal exception, # so we need to forcefully exit
if options.foreground: FOREGROUND = True if options.test_mode: TEST_NM = True if __name__ == '__main__': """ Start up the nodemanager. We are going to setup the servicelogger, then parse the arguments and then start everything up. """ # Initialize the service logger. We need to do this before calling main # because we want to print exceptions in main to the service log servicelogger.init('nodemanager') # Parse the arguments passed in the command line to set # different variables. parse_arguments() # Armon: Add some logging in case there is an uncaught exception try: main() except Exception, e: # If the servicelogger is not yet initialized, this will not be logged. servicelogger.log_last_exception() # Since the main thread has died, this is a fatal exception, # so we need to forcefully exit harshexit.harshexit(15)