2016-11-10 21:49:51 +01:00
|
|
|
import platform
|
2017-03-15 21:19:11 +01:00
|
|
|
import json
|
2017-04-26 20:18:41 +02:00
|
|
|
import subprocess
|
|
|
|
import os
|
2016-11-10 21:49:51 +01:00
|
|
|
|
|
|
|
from urllib2 import urlopen
|
2017-06-27 23:52:58 +02:00
|
|
|
from lbryschema import __version__ as lbryschema_version
|
|
|
|
from lbryum import __version__ as LBRYUM_VERSION
|
2017-04-26 20:18:41 +02:00
|
|
|
from lbrynet import build_type, __version__ as lbrynet_version
|
|
|
|
from lbrynet.conf import ROOT_DIR
|
2016-11-10 21:49:51 +01:00
|
|
|
|
|
|
|
|
2017-04-26 20:18:41 +02:00
|
|
|
def get_lbrynet_version():
|
|
|
|
if build_type.BUILD == "dev":
|
|
|
|
try:
|
|
|
|
with open(os.devnull, 'w') as devnull:
|
|
|
|
git_dir = ROOT_DIR + '/.git'
|
|
|
|
return subprocess.check_output(
|
|
|
|
['git', '--git-dir='+git_dir, 'describe', '--dirty', '--always'],
|
|
|
|
stderr=devnull
|
2017-05-03 19:00:01 +02:00
|
|
|
).strip().lstrip('v')
|
2017-04-26 20:18:41 +02:00
|
|
|
except (subprocess.CalledProcessError, OSError):
|
|
|
|
print "failed to get version from git"
|
|
|
|
return lbrynet_version
|
|
|
|
|
|
|
|
|
2017-03-15 21:19:11 +01:00
|
|
|
def get_platform(get_ip=True):
|
2016-11-10 21:49:51 +01:00
|
|
|
p = {
|
|
|
|
"processor": platform.processor(),
|
|
|
|
"python_version": platform.python_version(),
|
|
|
|
"platform": platform.platform(),
|
|
|
|
"os_release": platform.release(),
|
|
|
|
"os_system": platform.system(),
|
2017-04-26 20:18:41 +02:00
|
|
|
"lbrynet_version": get_lbrynet_version(),
|
|
|
|
"lbryum_version": LBRYUM_VERSION,
|
2017-04-19 19:54:38 +02:00
|
|
|
"lbryschema_version": lbryschema_version,
|
2017-03-15 21:33:41 +01:00
|
|
|
"build": build_type.BUILD, # CI server sets this during build step
|
2016-11-10 21:49:51 +01:00
|
|
|
}
|
|
|
|
|
2017-03-15 21:19:11 +01:00
|
|
|
if get_ip:
|
|
|
|
try:
|
|
|
|
p['ip'] = json.load(urlopen('http://jsonip.com'))['ip']
|
|
|
|
except:
|
|
|
|
p['ip'] = "Could not determine IP"
|
2016-11-10 21:49:51 +01:00
|
|
|
|
|
|
|
return p
|