def __init__(self): super(BinaryUpdateManager, self).__init__() self.base_url = 'http://xdm.lad1337.de/latest.php' self.branch = 'master' if version.build: self.branch = 'nightly' self.response.localVersion = common.getVersionHuman()
def __init__(self, args=None): if args is None: args = sys.argv[1:] p = argparse.ArgumentParser(prog='XDM') p.add_argument('-d', '--daemonize', action="store_true", dest='daemonize', help="Run the server as a daemon.") p.add_argument('-v', '--version', action="version", version='%s' % common.getVersionHuman()) p.add_argument('-D', '--debug', action="store_true", dest='debug', help="Print debug log to screen.") p.add_argument('-p', '--pidfile', dest='pidfile', default=None, help="Store the process id in the given file.") p.add_argument('-P', '--port', dest='port', type=int, default=None, help="Force webinterface to listen on this port.") p.add_argument('-n', '--nolaunch', action="store_true", dest='nolaunch', help="Don't start the browser.") p.add_argument('-b', '--datadir', dest='datadir', default=None, help="Set the directory for created data.") p.add_argument('--config_db', dest='config_db', default=None, help="Path to config database") p.add_argument('--data_db', dest='data_db', default=None, help="Path to data database") p.add_argument('--history_db', dest='history_db', default=None, help="Path to history database") p.add_argument('--dev', action="store_true", dest='dev', default=None, help="Developer mode. Disables the censoring during log and the plugin manager follows symlinks") p.add_argument('--noApi', action="store_true", dest='noApi', default=None, help="Disable the api") p.add_argument('--apiPort', dest='apiPort', type=int, default=None, help="Port the api runs on") p.add_argument('--noWebServer', action="store_true", dest='noWebServer', help="Don't start the webserver") p.add_argument('--pluginImportDebug', action="store_true", dest='pluginImportDebug', help="Extra verbosy debug during plugin import is printed.") p.add_argument('--profile', dest='profile', nargs='*', default=None, help="Wrap a decorated(!) function in a profiler. By default all decorated functions are profiled. Decorate your function with @profileMeMaybe") p.add_argument('--installType', dest='installType', default=None, type=int, help="Force the install type") options = p.parse_args(args) self.options = options common.STARTOPTIONS = options log.info('Starting XDM %s' % common.getVersionHuman()) # Set the Paths if options.datadir: datadir = options.datadir if not os.path.isdir(datadir): os.makedirs(datadir) elif hasattr(sys, 'frozen'): datadir = helper.getSystemDataDir(app_path) if not os.path.isdir(datadir): os.makedirs(datadir) else: datadir = app_path datadir = os.path.abspath(datadir) if not os.access(datadir, os.W_OK): raise SystemExit("Data dir must be writeable '" + datadir + "'") # setup file logger with datadir xdm.LOGPATH = os.path.join(datadir, xdm.LOGFILE) hdlr = logging.handlers.RotatingFileHandler(xdm.LOGPATH, maxBytes=10 * 1024 * 1024, backupCount=5) xdm.logger.fLogger.addHandler(hdlr) # Daemonize if options.daemonize: if sys.platform == 'win32': log.error("Daemonize not supported under Windows, starting normally") else: log.info("Preparing to run in daemon mode") logger.cLogger.setLevel(logging.CRITICAL) daemonize() # Debug if options.debug: logger.cLogger.setLevel(logging.DEBUG) log.info('XDM Debug mode ON') # Profile if options.profile is not None: log.info('XDM profiling mode ON') common.RUNPROFILER = True # PIDfile if options.pidfile: log.info("Set PIDfile to %s" % options.pidfile) PIDFile(cherrypy.engine, options.pidfile).subscribe() if options.pidfile: pid = str(os.getpid()) log(u"Writing PID %s to %s" % (pid, options.pidfile)) file(os.path.abspath(options.pidfile), 'w').write("%s\n" % pid) init.preDB(app_path, datadir) log.info("Logfile path is %s" % xdm.LOGPATH) init.db() init.postDB() init.schedule() # Set port if options.port: log.info("Port manual set to %d" % (options.port)) port = options.port server.socket_port = port else: port = common.SYSTEM.c.port server.socket_port = port self.port = server.socket_port # Set api port if options.apiPort: log.info("Api port manual set to %d" % (options.apiPort)) self.port_api = options.apiPort else: self.port_api = common.SYSTEM.c.port_api # update config for cherrypy cherrypy.config.update({'global': {'server.socket_port': port}})
def main(): print print "########################################" print "Starting build ..." print "########################################" buildParams = {} ###################### # check arguments # defaults buildParams['test'] = False buildParams['target'] = 'auto' buildParams['nightly'] = False buildParams['major'] = "" buildParams['minor'] = "" buildParams['revision'] = "" buildParams['branch'] = "" # win buildParams['py2ExeArgs'] = [] # not used yet # osx buildParams['onlyApp'] = False buildParams['py2AppArgs'] = ['py2app'] buildParams['osxDmgImage'] = "" buildParams['buildNumber'] = 0 try: opts, args = getopt.getopt(sys.argv[1:], "", [ 'test', 'onlyApp', 'nightly', 'dmgbg=', 'py2appArgs=', 'target=', 'major=', 'minor=', 'revision=', 'branch=', 'buildNumber=']) #@UnusedVariable except getopt.GetoptError: print "Available options: --test, --dmgbg, --onlyApp, --nightly, --py2appArgs, --target, --major, --minor, --revision, --branch, --buildNumber" exit(1) for o, a in opts: if o in ('--test'): buildParams['test'] = True if o in ('--nightly'): buildParams['nightly'] = True if o in ('--dmgbg'): buildParams['osxDmgImage'] = a if o in ('--onlyApp'): buildParams['onlyApp'] = True if o in ('--py2appArgs'): buildParams['py2AppArgs'] = py2AppArgs + a.split() if o in ('--dmgbg'): buildParams['osxDmgImage'] = a if o in ('--target'): buildParams['target'] = a if o in ('--major'): buildParams['major'] = int(a) if o in ('--minor'): buildParams['minor'] = int(a) if o in ('--revision'): buildParams['revision'] = int(a) if o in ('--branch'): buildParams['branch'] = a if o in ('--buildNumber'): buildParams['buildNumber'] = int(a) ###################### # constants buildParams['mainPy'] = "XDM.py" # this should never change buildParams['name'] = "XDM" # this should never change buildParams['majorVersion'] = "BETA" # one day we will change that to BETA :P buildParams['osName'] = getNiceOSString(buildParams)# look in getNiceOSString() for default os nice names """ # maybe some day the git tag is used this might be handy although it might be easier ti use the github lib # dynamic build number and date stuff tagsRaw = subprocess.Popen(["git", "tag"], stdout=subprocess.PIPE).communicate()[0] lastTagRaw = tagsRaw.split("\n")[-2] # current tag e.g. build-### tag = lastTagRaw.split("-")[1] # current tag pretty... change according to tag scheme """ # date stuff buildParams['thisYearString'] = date.today().strftime("%Y") # for the copyright notice buildParams['gitNewestCommit'], buildParams['gitNewestCommitShort'] = getLatestCommitID(buildParams) if not buildParams['branch']: buildParams['branch'] = getBranch(buildParams) buildParams['currentBranch'] = buildParams['branch'] else: buildParams['currentBranch'] = getBranch(buildParams) from xdm import common current_major, current_minor, current_revision, current_build = common.getVersionTuple() if not buildParams['major']: buildParams['major'] = current_major if not buildParams['minor']: buildParams['minor'] = current_minor if not buildParams['revision']: buildParams['revision'] = current_revision if not buildParams['buildNumber']: buildParams['buildNumber'] = current_build OLD_VERSION_CONTENT = None if buildParams['buildNumber']: print "we got a build number", buildParams['buildNumber'] # save old version.py OLD_VERSION_CONTENT = readXDMVersionFile() # write new version.py if not writeXDMVersionFile(buildParams['major'], buildParams['minor'], buildParams['revision'], buildParams['buildNumber']): print 'error while writing the new version file' exit(1) print readXDMVersionFile() # this is the 'branch yy.mm(.dd)' string buildParams['build'] = "%s %s" % (buildParams['branch'], common.getVersionHuman()) # or for nightlys yy.mm.commit if buildParams['nightly']: buildParams['build'] = "%s.%s" % (buildParams['dateVersion'], buildParams['gitNewestCommitShort']) buildParams['packageName'] = "%s-%s-%s" % (buildParams['name'] , buildParams['osName'] , buildParams['build']) # volume name buildParams['packageName'] = buildParams['packageName'].replace(" ", "-") ##################### # clean the build dirs scriptBuild = None scriptDist = None if not buildParams['test']: print "Removing old build dirs ...", # remove old build stuff if os.path.exists('build'): shutil.rmtree('build') if os.path.exists('dist'): shutil.rmtree('dist') # a windows build creats these folder too ... clear them scriptBuild = os.path.join('autoProcessTV', 'build') scriptDist = os.path.join('autoProcessTV', 'dist') if os.path.exists(scriptBuild): shutil.rmtree(scriptBuild) if os.path.exists(scriptDist): shutil.rmtree(scriptDist) # create build dirs acctualy only the dist has to be made manual because the changelog will be writen there os.makedirs('build') # create tmp build dir os.makedirs('dist') # create tmp build dir # TODO: do some real testing and dont just say ok print "ok" ##################### # write changelog #writeChangelog(buildParams) curFancyLogo = "" # os switch if buildParams['osName'] == 'OSX': result = buildOSX(buildParams) curFancyLogo = fancyLogoMac() elif buildParams['osName'] == 'Win': result = buildWIN(buildParams) curFancyLogo = fancyLogoWin() else: print "unknown os/target valid: OSX, Win" result = False if result: # reset version file if OLD_VERSION_CONTENT is not None: print print "########################################" print "Rewriting the old version file" print "########################################" writeXDMVersionFileRaw(OLD_VERSION_CONTENT) # remove the temp build dirs if os.path.exists('build'): shutil.rmtree('build') if scriptBuild and os.path.exists(scriptBuild): shutil.rmtree(scriptBuild) print curFancyLogo print print "########################################" print "Build SUCCESSFUL !!" print "########################################" exit() else: print print "########################################" print "ERROR during build ... i have failed you" print "########################################" exit(1)
def __init__(self): p = argparse.ArgumentParser(prog='XDM') p.add_argument('-d', '--daemonize', action="store_true", dest='daemonize', help="Run the server as a daemon.") p.add_argument('-v', '--version', action="store_true", dest='version', help="Print Version and exit.") p.add_argument('-D', '--debug', action="store_true", dest='debug', help="Print debug log to screen.") p.add_argument('-p', '--pidfile', dest='pidfile', default=None, help="Store the process id in the given file.") p.add_argument('-P', '--port', dest='port', default=None, help="Force webinterface to listen on this port.") p.add_argument('-n', '--nolaunch', action="store_true", dest='nolaunch', help="Don't start the browser.") p.add_argument('-b', '--datadir', dest='datadir', default=None, help="Set the directory for the database.") p.add_argument('-c', '--config', dest='config', default=None, help="Path to config file") p.add_argument('--dev', action="store_true", dest='dev', default=None, help="Developer mode. Disables the censoring during log and the plugin manager follows symlinks") p.add_argument('--noApi', action="store_true", dest='noApi', default=None, help="Disable the api") p.add_argument('--apiPort', dest='apiPort', default=None, help="Port the api runs on") p.add_argument('--noWebServer', action="store_true", dest='noWebServer', help="Port the api runs on") p.add_argument('--pluginImportDebug', action="store_true", dest='pluginImportDebug', help="Extra verbosy debug during plugin import is printed.") p.add_argument('--profile', dest='profile', nargs='*', default=None, help="Wrap a decorated(!) function in a profiler. By default all decorated functions are profiled. Decorate your function with @profileMeMaybe") options = p.parse_args() self.options = options common.STARTOPTIONS = options if options.version: print common.getVersionHuman() exit() log.info('Starting XDM %s' % common.getVersionHuman()) #Set the Paths if options.datadir: datadir = options.datadir if not os.path.isdir(datadir): os.makedirs(datadir) elif hasattr(sys, 'frozen'): datadir = helper.getSystemDataDir(app_path) if not os.path.isdir(datadir): os.makedirs(datadir) else: datadir = app_path datadir = os.path.abspath(datadir) if not os.access(datadir, os.W_OK): raise SystemExit("Data dir must be writeable '" + datadir + "'") # setup file logger with datadir hdlr = logging.handlers.RotatingFileHandler(os.path.join(datadir, 'xdm.log'), maxBytes=10 * 1024 * 1024, backupCount=5) xdm.logger.fLogger.addHandler(hdlr) #TODO: rewrite for the config.db """if options.config: config_path = options.config else: config_path = os.path.join(datadir, 'Gamez.ini')""" # Daemonize if options.daemonize: if sys.platform == 'win32': print "Daemonize not supported under Windows, starting normally" else: print "------------------- Preparing to run in daemon mode (screen logging is now OFF) -------------------" log.info("Preparing to run in daemon mode") logger.cLogger.setLevel(logging.CRITICAL) daemonize() # Debug if options.debug: print "------------------- XDM Debug Messages ON -------------------" logger.cLogger.setLevel(logging.DEBUG) log.info('XDM Debug mode ON') # Profile if options.profile is not None: print "------------------- XDM Profiling ON -------------------" log.info('XDM profiling mode ON') common.RUNPROFILER = True print common.RUNPROFILER init.preDB(app_path, datadir) init.db() init.postDB() init.schedule() init.runTasks() self.pluginResPaths = {} for pType, path in common.PM.path_cache.items(): self.pluginResPaths['/' + pType] = {'tools.staticdir.on': True, 'tools.staticdir.dir': os.path.abspath(path)} # Set port if options.port: print "------------------- Port manual set to " + options.port + " -------------------" port = int(options.port) server.socket_port = port else: port = common.SYSTEM.c.port server.socket_port = port self.port = server.socket_port # Set api port if options.apiPort: print "------------------- Api port manual set to " + options.apiPort + " -------------------" self.port_api = int(options.apiPort) else: self.port_api = common.SYSTEM.c.port_api # PIDfile if options.pidfile: print "------------------- Set PIDfile to " + options.pidfile + " -------------------" PIDFile(cherrypy.engine, options.pidfile).subscribe() # update config for cherrypy cherrypy.config.update({'global': {'server.socket_port': port}})
def install(self, identifier): self._prepareIntall() self.install_messages = [('info', 'install.py -i %s' % identifier)] self.setNewMessage('info', 'Getting download URL') plugin_to_update = None for repo in self.repos: for repo_plugin in repo.getPlugins(): if repo_plugin.identifier == identifier: plugin_to_update = repo_plugin break if plugin_to_update is None: self.setNewMessage('error', 'Could not find a plugin with identifier %s' % identifier) self.setNewMessage('info', 'Done!') return if not plugin_to_update.xdmMeetsVersionRequirement(): self.setNewMessage('error', 'The plugin requires XDM version %s or higher you have %s' % (common.makeVersionHuman(*plugin_to_update.xdm_version)), common.getVersionHuman()) self.setNewMessage('info', 'by the way how did you even get here ? the GUI should not have allowed this to begin with!') self.setNewMessage('info', 'Done!') return self.setNewMessage('info', 'Installing %s(%s)' % (plugin_to_update.name, plugin_to_update.versionHuman())) old_instalation = None for plugin in common.PM.getAll(returnAll=True, instance='Default'): if plugin.identifier == plugin_to_update.identifier: if not self._updateable(plugin_to_update, plugin): self.setNewMessage('error', '%s is already installed and does not need an update' % plugin_to_update.name) self.setNewMessage('info', 'Done!') return else: self.setNewMessage('info', '%s is already installed but has an update' % plugin_to_update.name) old_instalation = plugin break else: self.setNewMessage('info', '%s is not yet installed' % plugin_to_update.name) if old_instalation is not None: old_plugin_path = os.path.abspath(old_instalation.get_plugin_isntall_path()) old_plugin_path_parent = os.path.abspath(os.path.join(old_plugin_path, os.pardir)) self.setNewMessage('info', 'Renaming old install path %s' % old_plugin_path) new_dir = '__old__%s%s' % (plugin.type, plugin.version) new_dir = new_dir.replace(' ', '-').replace('.', '_') new_path = os.path.join(old_plugin_path_parent, new_dir) self.setNewMessage('info', 'to %s' % new_path) os.rename(old_plugin_path, new_path) if repo_plugin.format == 'zip': downloader = ZipPluginInstaller() else: self.setNewMessage('error', 'Format %s is not supported. sorry' % plugin_to_update.format) self.setNewMessage('info', 'Done!') return install_path = common.SYSTEM.c.extra_plugin_path self.setNewMessage('info', 'Installing into %s' % install_path) self.setNewMessage('info', 'Starting download. please wait...') install_result = False try: install_result = downloader.install(self, plugin_to_update, install_path) except Exception as ex: log.error('Something went wrong during download') self.setNewMessage('error', 'Error during download') self.setNewMessage('error', '%s' % ex) if install_result: self.setNewMessage('info', 'Installation successful') self.setNewMessage('info', 'Recaching plugins...') actionManager.executeAction('recachePlugins', ['RepoManager']) self.setNewMessage('info', 'Recaching pugins done.') self.setNewMessage('info', 'Recaching repos...') self.cache() self.setNewMessage('info', 'Recaching repos done. (please refresh page)') else: self.setNewMessage('error', 'Installation unsuccessful') self.setNewMessage('info', 'Done!')
def install(self, identifier, doCleanUp=True): self._prepareIntall() self.install_messages = [("info", "install.py -i %s" % identifier)] self.setNewMessage("info", "Getting download URL") plugin_to_update = None for repo in self.repos: for _repo_plugin in repo.getPlugins(): if _repo_plugin.identifier == identifier: plugin_to_update = _repo_plugin break if plugin_to_update is None: self.setNewMessage("error", "Could not find a plugin with identifier %s" % identifier) self.setNewMessage("info", "Done!") return if not plugin_to_update.xdmMeetsVersionRequirement(): self.setNewMessage( "error", "The plugin requires XDM version %s or higher you have %s" % (common.makeVersionHuman(*plugin_to_update.xdm_version)), common.getVersionHuman(), ) self.setNewMessage( "info", "by the way how did you even get here ? the GUI should not have allowed this to begin with!" ) self.setNewMessage("info", "Done!") return self.setNewMessage("info", "Installing %s(%s)" % (plugin_to_update.name, plugin_to_update.versionHuman())) old_instalation = None for plugin in common.PM.getAll(returnAll=True, instance="Default"): if plugin.identifier == plugin_to_update.identifier: if not self._updateable(plugin_to_update, plugin): self.setNewMessage( "error", "%s is already installed and does not need an update" % plugin_to_update.name ) self.setNewMessage("info", "Done!") return else: self.setNewMessage("info", "%s is already installed but has an update" % plugin_to_update.name) old_instalation = plugin break else: self.setNewMessage("info", "%s is not yet installed" % plugin_to_update.name) if old_instalation is not None: old_plugin_path = os.path.abspath(old_instalation.get_plugin_isntall_path()["path"]) old_plugin_path_parent = os.path.abspath(os.path.join(old_plugin_path, os.pardir)) self.setNewMessage("info", "Renaming old install path %s" % old_plugin_path) new_dir = "__old__%s %s %s" % (plugin.type, plugin.identifier, plugin.version) new_dir = new_dir.replace(" ", "-").replace(".", "_") new_path = os.path.join(old_plugin_path_parent, new_dir) self.setNewMessage("info", "to %s" % new_path) os.rename(old_plugin_path, new_path) if plugin_to_update.format == "zip": downloader = ZipPluginInstaller() else: self.setNewMessage("error", "Format %s is not supported. sorry" % plugin_to_update.format) self.setNewMessage("info", "Done!") return install_path = common.SYSTEM.c.extra_plugin_path self.setNewMessage("info", "Installing into %s" % install_path) if self.lastDownload != plugin_to_update.download_url: log( 'old: "%s" is not new: "%s", cleaning temp folder (%s) downloading new url and setting old to nothing.' % (self.lastDownload, plugin_to_update.download_url, xdm.TEMPPATH) ) helper.cleanTempFolder() self.lastDownload = "" self.setNewMessage("info", "Downloading, please wait...") else: self.setNewMessage("info", "Downloaded this file already.") install_result = False try: install_result = downloader.install(self, plugin_to_update, install_path) except Exception as ex: log.error("Something went wrong during download") self.setNewMessage("error", "Error during download") self.setNewMessage("error", "%s" % ex) if install_result: self.setNewMessage("info", "Installation successful!") if doCleanUp: self.doCleanUp() else: self.setNewMessage("error", "Installation unsuccessful!")
def __init__(self, args=None): if args is None: args = sys.argv[1:] p = argparse.ArgumentParser(prog="XDM") p.add_argument("-d", "--daemonize", action="store_true", dest="daemonize", help="Run the server as a daemon.") p.add_argument("-v", "--version", action="version", version="%s" % common.getVersionHuman()) p.add_argument("-D", "--debug", action="store_true", dest="debug", help="Print debug log to screen.") p.add_argument("-p", "--pidfile", dest="pidfile", default=None, help="Store the process id in the given file.") p.add_argument( "-P", "--port", dest="port", type=int, default=None, help="Force webinterface to listen on this port." ) p.add_argument("-n", "--nolaunch", action="store_true", dest="nolaunch", help="Don't start the browser.") p.add_argument("-b", "--datadir", dest="datadir", default=None, help="Set the directory for created data.") p.add_argument( "--configJSON", dest="configJSON", default=None, help="Set the path to the config JSON file (or folder with then) to read from", ) p.add_argument( "--systemIdentifer", dest="systemIdentifer", default="de.lad1337.systemconfig", help="Set the identifier for the system plugin", ) p.add_argument("--resetWizard", dest="reset_wizard", action="store_true", help="reset the wizard state") p.add_argument("--config_db", dest="config_db", default=None, help="Path to config database") p.add_argument("--data_db", dest="data_db", default=None, help="Path to data database") p.add_argument("--history_db", dest="history_db", default=None, help="Path to history database") p.add_argument( "--dev", action="store_true", dest="dev", default=None, help="Developer mode. Disables the censoring during log and the plugin manager follows symlinks", ) p.add_argument("--noApi", action="store_true", dest="noApi", default=None, help="Disable the api") p.add_argument("--apiPort", dest="apiPort", type=int, default=None, help="Port the api runs on") p.add_argument("--noWebServer", action="store_true", dest="noWebServer", help="Don't start the webserver") p.add_argument( "--pluginImportDebug", action="store_true", dest="pluginImportDebug", help="Extra verbosy debug during plugin import is printed.", ) p.add_argument( "--profile", dest="profile", nargs="*", default=None, help="Wrap a decorated(!) function in a profiler. By default all decorated functions are profiled. Decorate your function with @profileMeMaybe", ) p.add_argument("--installType", dest="installType", default=None, type=int, help="Force the install type") p.add_argument( "--config", dest="config", default=None, type=json.loads, help="Update the config with this json object" ) options = p.parse_args(args) self.options = options common.STARTOPTIONS = options log.info("Starting XDM %s" % common.getVersionHuman()) if options.configJSON: config_files = [] if os.path.isdir(options.configJSON): import glob config_files = [os.path.abspath(p) for p in glob.glob(os.path.join(options.configJSON, "*.json"))] else: config_files.append(os.path.abspath(options.configJSON)) for config_file in config_files: log.info("Loading config from file {}".format(config_file)) options = helper.spreadConfigsFromFile(options, config_file) if options.config: common.updateConfigOverwrite(options.config) # Set the Paths if options.datadir: datadir = options.datadir if not os.path.isdir(datadir): os.makedirs(datadir) elif hasattr(sys, "frozen"): datadir = helper.getSystemDataDir(app_path) if not os.path.isdir(datadir): os.makedirs(datadir) else: datadir = app_path datadir = os.path.abspath(datadir) if not os.access(datadir, os.W_OK): raise SystemExit("Data dir must be writeable '" + datadir + "'") # setup file logger with datadir xdm.LOGPATH = os.path.join(datadir, xdm.LOGFILE) hdlr = logging.handlers.RotatingFileHandler(xdm.LOGPATH, maxBytes=10 * 1024 * 1024, backupCount=5) xdm.logger.fLogger.addHandler(hdlr) # Daemonize if options.daemonize: if sys.platform == "win32": log.error("Daemonize not supported under Windows, starting normally") else: log.info("Preparing to run in daemon mode") logger.cLogger.setLevel(logging.CRITICAL) daemonize() # Debug if options.debug: logger.cLogger.setLevel(logging.DEBUG) log.info("XDM Debug mode ON") # Profile if options.profile is not None: log.info("XDM profiling mode ON") common.RUNPROFILER = True # PIDfile if options.pidfile: log.info("Set PIDfile to %s" % options.pidfile) PIDFile(cherrypy.engine, options.pidfile).subscribe() pid = str(os.getpid()) log(u"Writing PID %s to %s" % (pid, options.pidfile)) file(os.path.abspath(options.pidfile), "w").write("%s\n" % pid) init.preDB(app_path, datadir) log.info("Logfile path is %s" % xdm.LOGPATH) init.db() init.postDB() init.schedule() if options.reset_wizard: common.SYSTEM.hc.setup_wizard_step = 0 # Set port if options.port: log.info("Port manual set to %d" % (options.port)) port = options.port server.socket_port = port else: port = common.SYSTEM.c.port server.socket_port = port self.port = server.socket_port # Set api port if options.apiPort: log.info("Api port manual set to %d" % (options.apiPort)) self.port_api = options.apiPort else: self.port_api = common.SYSTEM.c.port_api # update config for cherrypy cherrypy.config.update({"global": {"server.socket_port": port}})
def install(self, identifier, doCleanUp=True): """install a plugin #. checks if plugin is already installed #. checks if plugins is installed but has an update, if so move the old version to __old__oldFolderName #. chooses install method by the given "format" e.g. "zip" #. use the Appropriate installer #. if doCleanUp was True doCleanUp_ is called .. _doCleanUp: """ self._prepareIntall() self.install_messages = [('info', 'install.py -i %s' % identifier)] self.setNewMessage('info', 'Getting download URL') plugin_to_update = None for repo in self.repos: for _repo_plugin in repo.getPlugins(): if _repo_plugin.identifier == identifier: plugin_to_update = _repo_plugin break if plugin_to_update is None: self.setNewMessage('error', 'Could not find a plugin with identifier %s' % identifier) self.setNewMessage('info', 'Done!') return if not plugin_to_update.xdmMeetsVersionRequirement(): self.setNewMessage('error', 'The plugin requires XDM version %s or higher you have %s' % (common.makeVersionHuman(*plugin_to_update.xdm_version)), common.getVersionHuman()) self.setNewMessage('info', 'by the way how did you even get here ? the GUI should not have allowed this to begin with!') self.setNewMessage('info', 'Done!') return self.setNewMessage('info', 'Installing %s(%s)' % (plugin_to_update.name, plugin_to_update.versionHuman())) old_instalation = None for plugin in common.PM.getAll(returnAll=True, instance='Default'): if plugin.identifier == plugin_to_update.identifier: if not self._updateable(plugin_to_update, plugin): self.setNewMessage('error', '%s is already installed and does not need an update' % plugin_to_update.name) self.setNewMessage('info', 'Done!') return else: self.setNewMessage('info', '%s is already installed but has an update' % plugin_to_update.name) old_instalation = plugin break else: self.setNewMessage('info', '%s is not yet installed' % plugin_to_update.name) if old_instalation is not None: old_plugin_path = os.path.abspath(old_instalation.get_plugin_isntall_path()['path']) old_plugin_path_parent = os.path.abspath(os.path.join(old_plugin_path, os.pardir)) self.setNewMessage('info', 'Renaming old install path %s' % old_plugin_path) new_dir = '__old__%s %s %s' % (plugin.type, plugin.identifier, plugin.version) new_dir = new_dir.replace(' ', '-').replace('.', '_') new_path = os.path.join(old_plugin_path_parent, new_dir) self.setNewMessage('info', 'to %s' % new_path) os.rename(old_plugin_path, new_path) if plugin_to_update.format == 'zip': downloader = ZipPluginInstaller() elif plugin_to_update.format == 'github': downloader = GithubPluginInstaller() else: self.setNewMessage('error', 'Format %s is not supported. sorry' % plugin_to_update.format) self.setNewMessage('info', 'Done!') return install_path = common.SYSTEM.c.extra_plugin_path self.setNewMessage('info', 'Installing into %s' % install_path) if self.lastDownload != plugin_to_update.download_url: log('old: "%s" is not new: "%s", cleaning temp folder (%s) downloading new url and setting old to nothing.' % (self.lastDownload, plugin_to_update.download_url, xdm.TEMPPATH)) helper.cleanTempFolder() self.lastDownload = '' self.setNewMessage('info', 'Downloading, please wait...') else: self.setNewMessage('info', 'Downloaded this file already.') install_result = False try: install_result = downloader.install(self, plugin_to_update, install_path) except Exception as ex: log.error('Something went wrong during download') self.setNewMessage('error', 'Error during download') self.setNewMessage('error', '%s' % ex) if install_result: self.setNewMessage('info', 'Installation successful!') if doCleanUp: self.doCleanUp() else: self.setNewMessage('error', 'Installation unsuccessful!')
def main(): print print "########################################" print "Starting build ..." print "########################################" buildParams = {} ###################### # check arguments # defaults buildParams['test'] = False buildParams['target'] = 'auto' buildParams['nightly'] = False buildParams['major'] = "" buildParams['minor'] = "" buildParams['revision'] = "" buildParams['branch'] = "" # win buildParams['py2ExeArgs'] = [] # not used yet # osx buildParams['onlyApp'] = False buildParams['py2AppArgs'] = ['py2app'] buildParams['osxDmgImage'] = "" buildParams['buildNumber'] = 0 try: opts, args = getopt.getopt(sys.argv[1:], "", [ 'test', 'onlyApp', 'nightly', 'dmgbg=', 'py2appArgs=', 'target=', 'major=', 'minor=', 'revision=', 'branch=', 'buildNumber=' ]) #@UnusedVariable except getopt.GetoptError: print "Available options: --test, --dmgbg, --onlyApp, --nightly, --py2appArgs, --target, --major, --minor, --revision, --branch, --buildNumber" exit(1) for o, a in opts: if o in ('--test'): buildParams['test'] = True if o in ('--nightly'): buildParams['nightly'] = True if o in ('--dmgbg'): buildParams['osxDmgImage'] = a if o in ('--onlyApp'): buildParams['onlyApp'] = True if o in ('--py2appArgs'): buildParams['py2AppArgs'] = py2AppArgs + a.split() if o in ('--dmgbg'): buildParams['osxDmgImage'] = a if o in ('--target'): buildParams['target'] = a if o in ('--major'): buildParams['major'] = int(a) if o in ('--minor'): buildParams['minor'] = int(a) if o in ('--revision'): buildParams['revision'] = int(a) if o in ('--branch'): buildParams['branch'] = a if o in ('--buildNumber'): buildParams['buildNumber'] = int(a) ###################### # constants buildParams['mainPy'] = "XDM.py" # this should never change buildParams['name'] = "XDM" # this should never change buildParams[ 'majorVersion'] = "BETA" # one day we will change that to BETA :P buildParams['osName'] = getNiceOSString( buildParams) # look in getNiceOSString() for default os nice names """ # maybe some day the git tag is used this might be handy although it might be easier ti use the github lib # dynamic build number and date stuff tagsRaw = subprocess.Popen(["git", "tag"], stdout=subprocess.PIPE).communicate()[0] lastTagRaw = tagsRaw.split("\n")[-2] # current tag e.g. build-### tag = lastTagRaw.split("-")[1] # current tag pretty... change according to tag scheme """ # date stuff buildParams['thisYearString'] = date.today().strftime( "%Y") # for the copyright notice buildParams['gitNewestCommit'], buildParams[ 'gitNewestCommitShort'] = getLatestCommitID(buildParams) if not buildParams['branch']: buildParams['branch'] = getBranch(buildParams) buildParams['currentBranch'] = buildParams['branch'] else: buildParams['currentBranch'] = getBranch(buildParams) from xdm import common current_major, current_minor, current_revision, current_build = common.getVersionTuple( ) if not buildParams['major']: buildParams['major'] = current_major if not buildParams['minor']: buildParams['minor'] = current_minor if not buildParams['revision']: buildParams['revision'] = current_revision if not buildParams['buildNumber']: buildParams['buildNumber'] = current_build OLD_VERSION_CONTENT = None if buildParams['buildNumber']: print "we got a build number", buildParams['buildNumber'] # save old version.py OLD_VERSION_CONTENT = readXDMVersionFile() # write new version.py if not writeXDMVersionFile(buildParams['major'], buildParams['minor'], buildParams['revision'], buildParams['buildNumber']): print 'error while writing the new version file' exit(1) print readXDMVersionFile() # this is the 'branch yy.mm(.dd)' string buildParams['build'] = "%s %s" % (buildParams['branch'], common.getVersionHuman()) # or for nightlys yy.mm.commit if buildParams['nightly']: buildParams['build'] = "%s.%s" % (buildParams['dateVersion'], buildParams['gitNewestCommitShort']) buildParams['packageName'] = "%s-%s-%s" % ( buildParams['name'], buildParams['osName'], buildParams['build'] ) # volume name buildParams['packageName'] = buildParams['packageName'].replace(" ", "-") ##################### # clean the build dirs scriptBuild = None scriptDist = None if not buildParams['test']: print "Removing old build dirs ...", # remove old build stuff if os.path.exists('build'): shutil.rmtree('build') if os.path.exists('dist'): shutil.rmtree('dist') # a windows build creats these folder too ... clear them scriptBuild = os.path.join('autoProcessTV', 'build') scriptDist = os.path.join('autoProcessTV', 'dist') if os.path.exists(scriptBuild): shutil.rmtree(scriptBuild) if os.path.exists(scriptDist): shutil.rmtree(scriptDist) # create build dirs acctualy only the dist has to be made manual because the changelog will be writen there os.makedirs('build') # create tmp build dir os.makedirs('dist') # create tmp build dir # TODO: do some real testing and dont just say ok print "ok" ##################### # write changelog #writeChangelog(buildParams) curFancyLogo = "" # os switch if buildParams['osName'] == 'OSX': result = buildOSX(buildParams) curFancyLogo = fancyLogoMac() elif buildParams['osName'] == 'Win': result = buildWIN(buildParams) curFancyLogo = fancyLogoWin() else: print "unknown os/target valid: OSX, Win" result = False if result: # reset version file if OLD_VERSION_CONTENT is not None: print print "########################################" print "Rewriting the old version file" print "########################################" writeXDMVersionFileRaw(OLD_VERSION_CONTENT) # remove the temp build dirs if os.path.exists('build'): shutil.rmtree('build') if scriptBuild and os.path.exists(scriptBuild): shutil.rmtree(scriptBuild) print curFancyLogo print print "########################################" print "Build SUCCESSFUL !!" print "########################################" exit() else: print print "########################################" print "ERROR during build ... i have failed you" print "########################################" exit(1)