コード例 #1
0
ファイル: launch.py プロジェクト: thedudeguy/yaMCat
class Launch:
    
    def __init__(self):
        self.daemon = YamcatDaemon('/tmp/yamcat.pid', stdout="/tmp/yamcat.log", stderr="/tmp/yamcat.log")
    
    def handle_args(self):
        """ Performs an action based on the sys.args """
        if len(sys.argv) == 2:
            if sys.argv[1] == 'start':
                self.start()
            elif sys.argv[1] == 'stop':
                self.stop()
            elif sys.argv[1] == 'startcli':
                self.startcli()
            else:
                self.help()
        else:
            self.help()
    
    def start(self):
        self.daemon.start()
        
    def stop(self):
        self.daemon.stop()
    
    def check_running(self):
        if self.daemon.is_running() == True:
            return True
        return False
    
    def startcli(self):
        if self.check_running() == True:
            sys.exit("yaMCat is already running in Daemon mode: cannot start")
        print "Starting in Non-Daemon mode"
        yamcatWeb.Server.quickstart()
    
    def help(self):
        """ Prints a help message to the user """
        self.license_info()
        print ""
        print "Usage: %s <command>" % sys.argv[0]
        print ""
        print "Commands:"
        print "   start - Start yaMCat in Daemon mode"
        print "   stop - Stop the yaMCat Daemon"
        print "   startcli - Start yaMCat in the terminal (Non-Daemon Mode)"
        print "   help - Show this help message"
        print ""
        
    def license_info(self):
        print "Copyright (C) 2011  Chris Churchwell"
        print "This program comes with ABSOLUTELY NO WARRANTY."
        print "This software is licensed under The GNU General Public License."
コード例 #2
0
ファイル: launch.py プロジェクト: thedudeguy/yaMCat
 def __init__(self):
     self.daemon = YamcatDaemon('/tmp/yamcat.pid', stdout="/tmp/yamcat.log", stderr="/tmp/yamcat.log")