diff --git a/common.py b/common.py index 8cb5335..42d5537 100644 --- a/common.py +++ b/common.py @@ -42,3 +42,18 @@ def logger(severity, message): # if severity in sev: args = (sys.argv[0], time.strftime('%Y-%m-%d.%H:%M:%S'), severity, message) sys.stderr.write(e('%s %s %s: %s' % args) + '\n') + +def get_version_git(): + import subprocess + + cmd = ['git', 'log', '-n', '1', '--oneline', '--abbrev-commit'] + + p = subprocess.Popen(cmd, bufsize=1, stdout=subprocess.PIPE) + first_line = p.stdout.readline() + + if 0 == p.wait(): + return "version (Git) '%s'" % e(first_line.strip()) + else: + return "(unknown version)" + +VERSION = get_version_git() diff --git a/local_config.py.skel b/local_config.py.skel index 670b7e1..1e8791c 100644 --- a/local_config.py.skel +++ b/local_config.py.skel @@ -18,9 +18,6 @@ config['hist_max_time'] = 10 * 60 config['uptime'] = -time.time() config['request_counter'] = 0 -config['version'] = None - - # the "dice" feature will use more efficient random data (0) for given users config['enhanced-random-user'] = ( 'FIXME', 'FIXME' ) diff --git a/plugins.py b/plugins.py index af6bc6a..fba4640 100644 --- a/plugins.py +++ b/plugins.py @@ -108,7 +108,7 @@ def command_version(args): if 'version' in args['data']: return { - 'msg': args['reply_user'] + (''': I'm running ''' + conf('version')) + 'msg': args['reply_user'] + (''': I'm running ''' + VERSION) } def command_unicode(args): diff --git a/urlbot.py b/urlbot.py index b397dd7..9825a16 100755 --- a/urlbot.py +++ b/urlbot.py @@ -187,19 +187,6 @@ def parse_delete(filepath): plugins.data_parse_other(content) return -def get_version_git(): - import subprocess - - cmd = ['git', 'log', '-n', '1', '--oneline', '--abbrev-commit'] - - p = subprocess.Popen(cmd, bufsize=1, stdout=subprocess.PIPE) - first_line = p.stdout.readline() - - if 0 == p.wait(): - return "version (Git) '%s'" % e(first_line.strip()) - else: - return "(unknown version)" - import plugins plugins.chat_write = chat_write @@ -209,8 +196,7 @@ plugins.ratelimit_touch = ratelimit_touch plugins.register_all() if '__main__' == __name__: - set_conf('version', get_version_git()) - print sys.argv[0] + ' ' + conf('version') + print sys.argv[0] + ' ' + VERSION if not os.path.exists(fifo_path): logger('error', 'fifo_path "%s" does not exist, exiting' % fifo_path)