Exemplo n.º 1
0
 def _wait(self):
   """Runs in a Twisted thread, just waiting for the process to finish"""
   if System.IS_WINDOWS:
     self.returnCode = System.wait_for_pid(self.pid)
     return True
   else:
     done = False
     while not done:
       #this is necessary because defunct processes in linux never count as exiting with this method
       #which means that this thread never ends, which means that we hang while shutting down
       if System.SHUTDOWN:
         return False
       try:
         #debug
         if type(self.pid) is not int:
           log_msg('self.pid is not int: %s' % (self.pid), 0)
         os.kill(self.pid, 0)
       except OSError:
         done = True
       time.sleep(0.5)
     return True
Exemplo n.º 2
0
 def _wait(self):
     """Runs in a Twisted thread, just waiting for the process to finish"""
     if System.IS_WINDOWS:
         self.returnCode = System.wait_for_pid(self.pid)
         return True
     else:
         done = False
         while not done:
             #this is necessary because defunct processes in linux never count as exiting with this method
             #which means that this thread never ends, which means that we hang while shutting down
             if System.SHUTDOWN:
                 return False
             try:
                 #debug
                 if type(self.pid) is not int:
                     log_msg('self.pid is not int: %s' % (self.pid), 0)
                 os.kill(self.pid, 0)
             except OSError:
                 done = True
             time.sleep(0.5)
         return True
Exemplo n.º 3
0
def read_args():
    #Create the options parser, this will be used throughout the program's execution
    Globals.PARSER = optparse.OptionParser()
    #Some options that are initially important:
    Globals.PARSER.add_option("--WAIT_FOR_PROCESS",
                              type="int",
                              dest="WAIT_FOR_PROCESS",
                              help="Dont use this",
                              metavar="FILE")
    Globals.PARSER.add_option("--FINISHED_UPDATE",
                              action="store_true",
                              dest="FINISHED_UPDATE",
                              default=False)
    Globals.PARSER.add_option("--use-existing-tor",
                              action="store_true",
                              dest="USE_EXISTING_TOR",
                              default=False)
    Globals.PARSER.add_option("-m",
                              "--minimize",
                              action="store_true",
                              dest="minimize",
                              default=False)
    Globals.PARSER.add_option("--curses",
                              action="store_true",
                              dest="useCurses",
                              default=False)
    Globals.PARSER.add_option("--no-gui",
                              action="store_true",
                              dest="no_gui",
                              default=False)
    Globals.PARSER.add_option("--allow-multiple",
                              action="store_true",
                              dest="allow_multiple",
                              default=False)
    Globals.PARSER.add_option("--dev-network",
                              action="store_true",
                              dest="dev_network",
                              default=False)
    Globals.PARSER.add_option("--debug",
                              action="store_true",
                              dest="debug",
                              default=False)
    #BitTorrent:
    Globals.PARSER.add_option("-t",
                              "--torrent",
                              dest="torrent",
                              help="Download a torrent file",
                              metavar="FILE")
    #for telling us which program to launch:
    Globals.PARSER.add_option("--launch-bt",
                              action="store_true",
                              dest="launch_bt",
                              default=False)
    Globals.PARSER.add_option("--launch-bb",
                              action="store_true",
                              dest="launch_bb",
                              default=False)
    Globals.PARSER.add_option("--launch-ff",
                              action="store_true",
                              dest="launch_ff",
                              default=False)
    #actually parse the options:
    (options, args) = Globals.PARSER.parse_args()

    #make sure that SOMETHING is supposed to start up:
    if not options.launch_bb and not options.launch_bt and not options.launch_ff:
        sys.argv.append('--launch-bb')
        options.launch_bb = True

    #NOTE:  weirdness:  the WAIT_FOR_PROCESS option is ONLY here for convenience.
    #It takes a process id as an argument.  All it does is wait for the process
    #with that pid and then exit.  This is called by the updater batch file,
    #because we need to wait for the previous InnomiNet instance to exit before
    #updating.  Because we use py2exe, I didnt want to make a separate script for that
    if options.WAIT_FOR_PROCESS:
        try:
            pid = options.WAIT_FOR_PROCESS
            log_msg(
                "Waiting on previous program (%s) to finish shutting down..." %
                (pid), 2)
            System.wait_for_pid(pid)
            log_msg("Finished waiting", 2)
        except Exception, error:
            log_ex(error, "WAIT_FOR_PROCESS failed")
        finally: