moved VERSION stuff to common.py

This commit is contained in:
urlbot
2014-09-27 09:41:29 +02:00
parent aae684170d
commit e721c328f7
4 changed files with 17 additions and 19 deletions

View File

@@ -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()

View File

@@ -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' )

View File

@@ -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):

View File

@@ -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)