def update(): """Run update routine """ if not util.does_file_exist('./.git/config'): util.Error( 'Not a git repo; please checkout from Github with \n\tgit clone http://github.com/hatRiot/zarp.git\n to update.' ) else: util.Msg('Updating Zarp...') ret = util.init_app('git branch -a | grep \'* dev\'', True) if len(ret) > 3: util.Error( 'You appear to be on the dev branch. Please switch off dev to update.' ) return ret = util.init_app('git pull git://github.com/hatRiot/zarp.git HEAD', True) if 'Already up-to-date' in ret: util.Msg('Zarp already up to date.') elif 'fatal' in ret: util.Error('Error updating Zarp: %s' % ret) else: from util import version util.Msg('Zarp updated to version %s' % (version()))
def version(orig, ui, *args, **opts): svn = opts.pop('svn', None) orig(ui, *args, **opts) if svn: svnversion, bindings = svnwrap.version() ui.status('\n') ui.status('hgsubversion: %s\n' % util.version(ui)) ui.status('Subversion: %s\n' % svnversion) ui.status('bindings: %s\n' % bindings)
def update(): if not util.does_file_exist('./.git/config'): util.Error('Not a git repo; please checkout from Github with \n\tgit clone http://github.com/hatRiot/zarp.git\n to update.') else: util.Msg('Updating Zarp...') ret = util.init_app('git branch -a | grep \'* dev\'', True) if len(ret) > 3: util.Error('You appear to be on the dev branch. Please switch off dev to update.') return ret = util.init_app('git pull git://github.com/hatRiot/zarp.git HEAD', True) if 'Already up-to-date' in ret: util.Msg('Zarp already up to date.') elif 'fatal' in ret: util.Error('Error updating Zarp: %s'%ret) else: from util import version util.Msg('Zarp updated to version %s'%(version()))
def __init__(self, config): self.config = config self.host = config.get('controller', 'host', default='localhost') self.port = config.getint('controller', 'port', default=8888) self.proxy = config.getboolean('controller', 'proxy', default=False) if self.proxy: self.proxy_connect_port = config.getint('controller', 'proxy_connect_port') self.ssl = config.getboolean('controller', 'ssl', default=True) self.data_dir = config.get('controller', 'data-dir', default=self.DEFAULT_DATA_DIR) if not os.path.isdir(self.data_dir): os.mkdir(self.data_dir) for sub_dir in ["data", "archive", "logs/archive"]: tdir = os.path.join(self.data_dir, sub_dir) if not os.path.isdir(tdir): os.makedirs(tdir) self.uuid = config.get(self.DEFAULT_SECTION, 'uuid') self.version = version() self.license_key = config.get(self.DEFAULT_SECTION, 'license-key', default=self.DEFAULT_LICENSE_KEY) self.archive_port = config.get('archive', 'port', default=8889) self.install_dir = os.path.abspath(os.path.dirname(__file__)) self.xid_dir = config.get(self.DEFAULT_SECTION, 'xid-dir', default=None) if not self.xid_dir: self.xid_dir = os.path.join(self.install_dir, 'xid') if not os.path.isdir(self.xid_dir): os.mkdir(self.xid_dir) pathenv = config.get(self.DEFAULT_SECTION, 'path', default=None) self.processmanager = ProcessManager(self.xid_dir, pathenv) conf = os.path.join(self.install_dir, 'conf', 'archive', 'httpd.conf') port = config.getint("archive", "port", default=8889); self.archive = Apache2(conf, port, self.data_dir)
def aboutDialog(self): about = wx.AboutDialogInfo() about.Name = 'wxproute' about.Version = guiconfig.version() about.Copyright = '(C) Fabien Tricoire 2010-2011' description = '\nproute engine version ' + util.version() description += '\n\nwxPython version ' + wx.version() try: description += '\n\nReportLab version ' + reportlab.Version except Exception as e: description += '\n\nReportLab not installed' try: description += '\n\nPython Imaging Library (PIL) version ' + \ Image.VERSION except Exception as e: description += '\n\nPython Imaging Library (PIL) not installed' about.Description = wordwrap(description, 500, wx.ClientDC(self)) about.WebSite = ('http://proute.berlios.de/', 'proute home page') about.Developers = [ 'Fabien Tricoire' ] licenseText = '' about.License = wordwrap(licenseText, 500, wx.ClientDC(self)) # wx.AboutBox(about)
def aboutDialog(self): about = wx.AboutDialogInfo() about.Name = 'wxproute' about.Version = guiconfig.version() about.Copyright = '(C) Fabien Tricoire 2010-2011' description = '\nproute engine version ' + util.version() description += '\n\nwxPython version ' + wx.version() try: description += '\n\nReportLab version ' + reportlab.Version except Exception as e: description += '\n\nReportLab not installed' try: description += '\n\nPython Imaging Library (PIL) version ' + \ Image.VERSION except Exception as e: description += '\n\nPython Imaging Library (PIL) not installed' about.Description = wordwrap(description, 500, wx.ClientDC(self)) about.WebSite = ('http://proute.berlios.de/', 'proute home page') about.Developers = ['Fabien Tricoire'] licenseText = '' about.License = wordwrap(licenseText, 500, wx.ClientDC(self)) # wx.AboutBox(about)
def update(): """Run update routine """ if not util.does_file_exist("./.git/config"): util.Error( "Not a git repo; please checkout from Github with \n\t" "git clone http://github.com/hatRiot/zarp.git\n to update." ) else: util.Msg("Updating Zarp...") ret = util.init_app("git branch -a | grep '* dev'", True) if len(ret) > 3: util.Error("You appear to be on the dev branch." "Please switch off dev to update.") return ret = util.init_app("git pull git://github.com/hatRiot/zarp.git HEAD") if "Already up-to-date" in ret: util.Msg("Zarp already up to date.") elif "fatal" in ret: util.Error("Error updating Zarp: %s" % ret) else: from util import version util.Msg("Zarp updated to version %s" % (version()))
except IOError, inst: if inst.errno == errno.EPIPE: if ui.debugflag: ui.warn(_("\nbroken pipe\n")) else: raise except MemoryError: ui.warn(_("abort: out of memory\n")) except SystemExit, inst: # Commands shouldn't sys.exit directly, but give a return code. # Just in case catch this and and pass exit code to caller. return inst.code except socket.error, inst: ui.warn(_("abort: %s\n") % inst.args[-1]) except: # re-raises myver = util.version() # For compatibility checking, we discard the portion of the hg # version after the + on the assumption that if a "normal # user" is running a build with a + in it the packager # probably built from fairly close to a tag and anyone with a # 'make local' copy of hg (where the version number can be out # of date) will be clueful enough to notice the implausible # version number and try updating. compare = myver.split("+")[0] ct = tuplever(compare) worst = None, ct, "" for name, mod in extensions.extensions(): testedwith = getattr(mod, "testedwith", "") report = getattr(mod, "buglink", _("the extension author.")) if not testedwith.strip(): # We found an untested extension. It's likely the culprit.
def _runcatch(req): def catchterm(*args): raise error.SignalInterrupt ui = req.ui try: for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM': num = getattr(signal, name, None) if num: signal.signal(num, catchterm) except ValueError: pass # happens if called in a thread try: try: debugger = 'pdb' debugtrace = { 'pdb' : pdb.set_trace } debugmortem = { 'pdb' : pdb.post_mortem } # read --config before doing anything else # (e.g. to change trust settings for reading .hg/hgrc) cfgs = _parseconfig(req.ui, _earlygetopt(['--config'], req.args)) if req.repo: # copy configs that were passed on the cmdline (--config) to # the repo ui for sec, name, val in cfgs: req.repo.ui.setconfig(sec, name, val, source='--config') # if we are in HGPLAIN mode, then disable custom debugging debugger = ui.config("ui", "debugger") debugmod = pdb if not debugger or ui.plain(): debugger = 'pdb' elif '--debugger' in req.args: # This import can be slow for fancy debuggers, so only # do it when absolutely necessary, i.e. when actual # debugging has been requested with demandimport.deactivated(): try: debugmod = __import__(debugger) except ImportError: pass # Leave debugmod = pdb debugtrace[debugger] = debugmod.set_trace debugmortem[debugger] = debugmod.post_mortem # enter the debugger before command execution if '--debugger' in req.args: ui.warn(_("entering debugger - " "type c to continue starting hg or h for help\n")) if (debugger != 'pdb' and debugtrace[debugger] == debugtrace['pdb']): ui.warn(_("%s debugger specified " "but its module was not found\n") % debugger) debugtrace[debugger]() try: return _dispatch(req) finally: ui.flush() except: # re-raises # enter the debugger when we hit an exception if '--debugger' in req.args: traceback.print_exc() debugmortem[debugger](sys.exc_info()[2]) ui.traceback() raise # Global exception handling, alphabetically # Mercurial-specific first, followed by built-in and library exceptions except error.AmbiguousCommand as inst: ui.warn(_("hg: command '%s' is ambiguous:\n %s\n") % (inst.args[0], " ".join(inst.args[1]))) except error.ParseError as inst: _formatparse(ui.warn, inst) return -1 except error.LockHeld as inst: if inst.errno == errno.ETIMEDOUT: reason = _('timed out waiting for lock held by %s') % inst.locker else: reason = _('lock held by %s') % inst.locker ui.warn(_("abort: %s: %s\n") % (inst.desc or inst.filename, reason)) except error.LockUnavailable as inst: ui.warn(_("abort: could not lock %s: %s\n") % (inst.desc or inst.filename, inst.strerror)) except error.CommandError as inst: if inst.args[0]: ui.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1])) commands.help_(ui, inst.args[0], full=False, command=True) else: ui.warn(_("hg: %s\n") % inst.args[1]) commands.help_(ui, 'shortlist') except error.OutOfBandError as inst: if inst.args: msg = _("abort: remote error:\n") else: msg = _("abort: remote error\n") ui.warn(msg) if inst.args: ui.warn(''.join(inst.args)) if inst.hint: ui.warn('(%s)\n' % inst.hint) except error.RepoError as inst: ui.warn(_("abort: %s!\n") % inst) if inst.hint: ui.warn(_("(%s)\n") % inst.hint) except error.ResponseError as inst: ui.warn(_("abort: %s") % inst.args[0]) if not isinstance(inst.args[1], basestring): ui.warn(" %r\n" % (inst.args[1],)) elif not inst.args[1]: ui.warn(_(" empty string\n")) else: ui.warn("\n%r\n" % util.ellipsis(inst.args[1])) except error.CensoredNodeError as inst: ui.warn(_("abort: file censored %s!\n") % inst) except error.RevlogError as inst: ui.warn(_("abort: %s!\n") % inst) except error.SignalInterrupt: ui.warn(_("killed!\n")) except error.UnknownCommand as inst: ui.warn(_("hg: unknown command '%s'\n") % inst.args[0]) try: # check if the command is in a disabled extension # (but don't check for extensions themselves) commands.help_(ui, inst.args[0], unknowncmd=True) except error.UnknownCommand: suggested = False if len(inst.args) == 2: sim = _getsimilar(inst.args[1], inst.args[0]) if sim: ui.warn(_('(did you mean one of %s?)\n') % ', '.join(sorted(sim))) suggested = True if not suggested: commands.help_(ui, 'shortlist') except error.InterventionRequired as inst: ui.warn("%s\n" % inst) return 1 except util.Abort as inst: ui.warn(_("abort: %s\n") % inst) if inst.hint: ui.warn(_("(%s)\n") % inst.hint) except ImportError as inst: ui.warn(_("abort: %s!\n") % inst) m = str(inst).split()[-1] if m in "mpatch bdiff".split(): ui.warn(_("(did you forget to compile extensions?)\n")) elif m in "zlib".split(): ui.warn(_("(is your Python install correct?)\n")) except IOError as inst: if util.safehasattr(inst, "code"): ui.warn(_("abort: %s\n") % inst) elif util.safehasattr(inst, "reason"): try: # usually it is in the form (errno, strerror) reason = inst.reason.args[1] except (AttributeError, IndexError): # it might be anything, for example a string reason = inst.reason if isinstance(reason, unicode): # SSLError of Python 2.7.9 contains a unicode reason = reason.encode(encoding.encoding, 'replace') ui.warn(_("abort: error: %s\n") % reason) elif (util.safehasattr(inst, "args") and inst.args and inst.args[0] == errno.EPIPE): if ui.debugflag: ui.warn(_("broken pipe\n")) elif getattr(inst, "strerror", None): if getattr(inst, "filename", None): ui.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename)) else: ui.warn(_("abort: %s\n") % inst.strerror) else: raise except OSError as inst: if getattr(inst, "filename", None) is not None: ui.warn(_("abort: %s: '%s'\n") % (inst.strerror, inst.filename)) else: ui.warn(_("abort: %s\n") % inst.strerror) except KeyboardInterrupt: try: ui.warn(_("interrupted!\n")) except IOError as inst: if inst.errno == errno.EPIPE: if ui.debugflag: ui.warn(_("\nbroken pipe\n")) else: raise except MemoryError: ui.warn(_("abort: out of memory\n")) except SystemExit as inst: # Commands shouldn't sys.exit directly, but give a return code. # Just in case catch this and and pass exit code to caller. return inst.code except socket.error as inst: ui.warn(_("abort: %s\n") % inst.args[-1]) except: # re-raises myver = util.version() # For compatibility checking, we discard the portion of the hg # version after the + on the assumption that if a "normal # user" is running a build with a + in it the packager # probably built from fairly close to a tag and anyone with a # 'make local' copy of hg (where the version number can be out # of date) will be clueful enough to notice the implausible # version number and try updating. compare = myver.split('+')[0] ct = tuplever(compare) worst = None, ct, '' for name, mod in extensions.extensions(): testedwith = getattr(mod, 'testedwith', '') report = getattr(mod, 'buglink', _('the extension author.')) if not testedwith.strip(): # We found an untested extension. It's likely the culprit. worst = name, 'unknown', report break # Never blame on extensions bundled with Mercurial. if testedwith == 'internal': continue tested = [tuplever(t) for t in testedwith.split()] if ct in tested: continue lower = [t for t in tested if t < ct] nearest = max(lower or tested) if worst[0] is None or nearest < worst[1]: worst = name, nearest, report if worst[0] is not None: name, testedwith, report = worst if not isinstance(testedwith, str): testedwith = '.'.join([str(c) for c in testedwith]) warning = (_('** Unknown exception encountered with ' 'possibly-broken third-party extension %s\n' '** which supports versions %s of Mercurial.\n' '** Please disable %s and try your action again.\n' '** If that fixes the bug please report it to %s\n') % (name, testedwith, name, report)) else: warning = (_("** unknown exception encountered, " "please report by visiting\n") + _("** http://mercurial.selenic.com/wiki/BugTracker\n")) warning += ((_("** Python %s\n") % sys.version.replace('\n', '')) + (_("** Mercurial Distributed SCM (version %s)\n") % myver) + (_("** Extensions loaded: %s\n") % ", ".join([x[0] for x in extensions.extensions()]))) ui.log("commandexception", "%s\n%s\n", warning, traceback.format_exc()) ui.warn(warning) raise return -1
except MemoryError: ui.warn(_("abort: out of memory\n")) except SystemExit, inst: # Commands shouldn't sys.exit directly, but give a return code. # Just in case catch this and and pass exit code to caller. return inst.code except socket.error, inst: ui.warn(_("abort: %s\n") % inst.args[-1]) except: ui.warn(_("** unknown exception encountered, details follow\n")) ui.warn( _("** report bug details to " "http://mercurial.selenic.com/bts/\n")) ui.warn(_("** or [email protected]\n")) ui.warn( _("** Mercurial Distributed SCM (version %s)\n") % util.version()) ui.warn( _("** Extensions loaded: %s\n") % ", ".join([x[0] for x in extensions.extensions()])) raise return -1 def aliasargs(fn): if hasattr(fn, 'args'): return fn.args return [] class cmdalias(object):
raise except MemoryError: ui.warn(_("abort: out of memory\n")) except SystemExit, inst: # Commands shouldn't sys.exit directly, but give a return code. # Just in case catch this and and pass exit code to caller. return inst.code except socket.error, inst: ui.warn(_("abort: %s\n") % inst.args[-1]) except: ui.warn(_("** unknown exception encountered," " please report by visiting\n")) ui.warn(_("** http://mercurial.selenic.com/wiki/BugTracker\n")) ui.warn(_("** Python %s\n") % sys.version.replace('\n', '')) ui.warn(_("** Mercurial Distributed SCM (version %s)\n") % util.version()) ui.warn(_("** Extensions loaded: %s\n") % ", ".join([x[0] for x in extensions.extensions()])) raise return -1 def aliasargs(fn): if hasattr(fn, 'args'): return fn.args return [] class cmdalias(object): def __init__(self, name, definition, cmdtable): self.name = self.cmd = name self.cmdname = ''
def licensing_info(domain, envid, system): """Don't do anything very active since this can run when in UPGRADE state, etc.""" data = {} data['license-key'] = domain.license_key data['system-id'] = domain.systemid data['expiration-time'] = domain.expiration_time data['contact-time'] = domain.contact_time data['trial'] = domain.trial data['platform-product'] = system[SystemKeys.PLATFORM_PRODUCT] data['platform-image'] = system[SystemKeys.PLATFORM_IMAGE] data['platform-location'] = system[SystemKeys.PLATFORM_LOCATION] data['auto-update-enabled'] = system[SystemKeys.AUTO_UPDATE_ENABLED] data['support-enabled'] = system[SystemKeys.SUPPORT_ENABLED] # FIXME: use the version() function when sorted out. data['palette-version'] = version() data['repo'] = _repo() try: agent = meta.Session.query(Agent).\ filter(Agent.agent_type == AgentManager.AGENT_TYPE_PRIMARY).\ one() except NoResultFound: # print "No primary agents ever connected." return data entry = LicenseEntry.get_by_agentid(agent.agentid) if not entry: logging.debug("No tableau license entry yet.") return data data['license-type'] = entry.license_type if entry.license_type == LicenseEntry.LICENSE_TYPE_NAMED_USER: data['license-quantity'] = entry.interactors elif entry.license_type == LicenseEntry.LICENSE_TYPE_CORE: data['license-quantity'] = entry.cores # used data['license-core-licenses'] = entry.core_licenses # available/bought else: data['license-quantity'] = None data['tableau-version'] = YmlEntry.get(envid, 'version.external', default='unknown') data['tableau-bitness'] = YmlEntry.get(envid, 'version.bitness', default='unknown') data['processor-type'] = agent.processor_type data['processor-count'] = agent.processor_count data['processor-bitness'] = agent.bitness data['primary-uuid'] = agent.uuid data['primary-os-version'] = agent.os_version agents = meta.Session.query(Agent).\ all() agent_info = [] for agent in agents: agent_info.append({ 'displayname': agent.displayname, 'hostname': agent.hostname, 'type': agent.agent_type, 'version': agent.version }) data['agent-info'] = agent_info return data
def nagios_bot_get(request): """ Respond with simple hello. """ return web.Response(text=version())
raise except MemoryError: ui.warn(_("abort: out of memory\n")) except SystemExit, inst: # Commands shouldn't sys.exit directly, but give a return code. # Just in case catch this and and pass exit code to caller. return inst.code except socket.error, inst: ui.warn(_("abort: %s\n") % inst.args[-1]) except: ui.warn(_("** unknown exception encountered," " please report by visiting\n")) ui.warn(_("** http://mercurial.selenic.com/wiki/BugTracker\n")) ui.warn(_("** Python %s\n") % sys.version.replace('\n', '')) ui.warn(_("** Mercurial Distributed SCM (version %s)\n") % util.version()) ui.warn(_("** Extensions loaded: %s\n") % ", ".join([x[0] for x in extensions.extensions()])) raise return -1 def aliasargs(fn, givenargs): args = getattr(fn, 'args', []) if args and givenargs: cmd = ' '.join(map(util.shellquote, args)) nums = [] def replacer(m): num = int(m.group(1)) - 1 nums.append(num)
except IOError, inst: if inst.errno == errno.EPIPE: if ui.debugflag: ui.warn(_("\nbroken pipe\n")) else: raise except MemoryError: ui.warn(_("abort: out of memory\n")) except SystemExit, inst: # Commands shouldn't sys.exit directly, but give a return code. # Just in case catch this and and pass exit code to caller. return inst.code except socket.error, inst: ui.warn(_("abort: %s\n") % inst.args[-1]) except: # re-raises myver = util.version() # For compatibility checking, we discard the portion of the hg # version after the + on the assumption that if a "normal # user" is running a build with a + in it the packager # probably built from fairly close to a tag and anyone with a # 'make local' copy of hg (where the version number can be out # of date) will be clueful enough to notice the implausible # version number and try updating. compare = myver.split('+')[0] ct = tuplever(compare) worst = None, ct, '' for name, mod in extensions.extensions(): testedwith = getattr(mod, 'testedwith', '') report = getattr(mod, 'buglink', _('the extension author.')) if not testedwith.strip(): # We found an untested extension. It's likely the culprit.
context.update({"LOCAL_APP_PATH": local_app_path}) context.update(config.get("PROVISION", {})) context.update(config.get("DEPLOY", {})) if pubpublica_config := config.get("PUBPUBLICA"): context.update({"PUBPUBLICA": pubpublica_config}) if flask_config := config.get("FLASK"): context.update({"FLASK": flask_config}) if redis_config := config.get("REDIS"): context.update({"REDIS": redis_config}) version_file = os.path.join(local_app_path, "__version__.py") version = util.version(version_file) context.update({"LOCAL_VERSION": version}) commit = git.latest_commit_hash(c, local_app_path) context.update({"COMMIT_HASH": commit}) context.update({"SHORT_COMMIT_HASH": commit[:7]}) timestamp = util.timestamp() context.update({"TIMESTAMP": timestamp}) return context def check_local_git_repo(c, ctx): with Guard("· checking local git repo..."): root = ctx.get("LOCAL_APP_PATH")