forked from 0x2620/pandora
check for release in update.py by default
This commit is contained in:
parent
8e863fd4e3
commit
d83b6988ab
1 changed files with 64 additions and 31 deletions
95
update.py
95
update.py
|
@ -11,6 +11,8 @@ if os.path.exists(activate_this):
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import ox
|
||||||
|
import json
|
||||||
from os.path import join, exists
|
from os.path import join, exists
|
||||||
|
|
||||||
def run(*cmd):
|
def run(*cmd):
|
||||||
|
@ -23,11 +25,30 @@ def get(*cmd):
|
||||||
stdout, error = p.communicate()
|
stdout, error = p.communicate()
|
||||||
return stdout
|
return stdout
|
||||||
|
|
||||||
|
def get_release():
|
||||||
|
try:
|
||||||
|
return json.loads(ox.net.read_url('https://pan.do/json/release.json'))
|
||||||
|
except:
|
||||||
|
print "failed to load https://pan.do/ra, check your internet connection"
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
repos = {
|
repos = {
|
||||||
"pandora": "http://code.0x2620.org/pandora/",
|
"pandora": {
|
||||||
"oxjs": "http://code.0x2620.org/oxjs/",
|
"url": "http://code.0x2620.org/pandora/",
|
||||||
"python-ox": "http://code.0x2620.org/python-ox/",
|
"path": ".",
|
||||||
"oxtimelines": "http://code.0x2620.org/oxtimelines/",
|
},
|
||||||
|
"oxjs": {
|
||||||
|
"url": "http://code.0x2620.org/oxjs/",
|
||||||
|
"path": "./static/oxjs",
|
||||||
|
},
|
||||||
|
"oxtimelines": {
|
||||||
|
"url": "http://code.0x2620.org/oxtimelines/",
|
||||||
|
"path": "./src/oxtimelines",
|
||||||
|
},
|
||||||
|
"python-ox": {
|
||||||
|
"url": "http://code.0x2620.org/python-ox/",
|
||||||
|
"path": "./src/python-ox",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def reload_notice(base):
|
def reload_notice(base):
|
||||||
|
@ -52,38 +73,50 @@ if __name__ == "__main__":
|
||||||
print "\t./manage.py migrate --all --fake"
|
print "\t./manage.py migrate --all --fake"
|
||||||
print "Check http://wiki.0x2620.org/wiki/pandora/DatabaseUpdate for more information"
|
print "Check http://wiki.0x2620.org/wiki/pandora/DatabaseUpdate for more information"
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
if len(sys.argv) == 1:
|
||||||
|
release = get_release()
|
||||||
|
repos = release['repos']
|
||||||
|
development = False
|
||||||
|
else:
|
||||||
|
release = {
|
||||||
|
'date': 'development'
|
||||||
|
}
|
||||||
|
development = True
|
||||||
os.chdir(base)
|
os.chdir(base)
|
||||||
current = get('bzr', 'revno')
|
current = ''
|
||||||
run('bzr', 'pull', repos['pandora'])
|
new = ''
|
||||||
new = get('bzr', 'revno')
|
for repo in repos:
|
||||||
|
path = os.path.join(base, repos[repo]['path'])
|
||||||
if exists(join(base, 'static', 'oxjs')):
|
if exists(path):
|
||||||
os.chdir(join(base, 'static', 'oxjs'))
|
os.chdir(path)
|
||||||
current += get('bzr', 'revno')
|
revno = get('bzr', 'revno')
|
||||||
run('bzr', 'pull', repos['oxjs'])
|
current += revno
|
||||||
new += get('bzr', 'revno')
|
url = repos[repo]['url']
|
||||||
else:
|
if 'revision' in repos[repo]:
|
||||||
os.chdir(join(base, 'static'))
|
if int(revno) < repos[repo]['revision']:
|
||||||
run('bzr', 'branch', repos['oxjs'])
|
run('bzr', 'pull', url, '-r', '%s' % repos[repo]['revision'])
|
||||||
new += '+'
|
else:
|
||||||
|
run('bzr', 'pull', url)
|
||||||
if exists(join(base, 'src', 'python-ox')):
|
revno = get('bzr', 'revno')
|
||||||
os.chdir(join(base, 'src', 'python-ox'))
|
new += revno
|
||||||
current += get('bzr', 'revno')
|
else:
|
||||||
run('bzr', 'pull', repos['python-ox'])
|
os.chdir(os.path.dirname(path))
|
||||||
new += get('bzr', 'revno')
|
cmd = ['bzr', 'branch', repos[repo]['url']]
|
||||||
|
if 'revision' in repos[repo]:
|
||||||
if exists(join(base, 'src', 'oxtimelines')):
|
cmd += ['-r', '%s' % repos[repo]['revision']]
|
||||||
os.chdir(join(base, 'src', 'oxtimelines'))
|
run(*cmd)
|
||||||
current += get('bzr', 'revno')
|
setup = os.path.join(base, repos[repo]['path'], 'setup.py')
|
||||||
run('bzr', 'pull', repos['oxtimelines'])
|
if repo in ('python-ox', 'oxtimelines') and os.path.exists(setup):
|
||||||
new += get('bzr', 'revno')
|
os.chdir(os.path.dirname(setup))
|
||||||
else:
|
run(os.path.join(base, 'bin', 'python'), 'setup.py', 'develop')
|
||||||
print "oxtimelines is missing. please run:\n\n\tcd %s\n\tpip -E . install -r requirements.txt\n" % (base)
|
new += '+'
|
||||||
os.chdir(join(base, 'pandora'))
|
os.chdir(join(base, 'pandora'))
|
||||||
if current != new:
|
if current != new:
|
||||||
run('./manage.py', 'update_static')
|
run('./manage.py', 'update_static')
|
||||||
run('./manage.py', 'compile_pyc')
|
run('./manage.py', 'compile_pyc')
|
||||||
|
elif not development:
|
||||||
|
print 'pan.do/ra is up to date, run "./update development" to update to the current development version'
|
||||||
diff = get('./manage.py', 'sqldiff', '-a').strip()
|
diff = get('./manage.py', 'sqldiff', '-a').strip()
|
||||||
if diff != '-- No differences':
|
if diff != '-- No differences':
|
||||||
print 'Database has changed, please make a backup and run ./update.py database'
|
print 'Database has changed, please make a backup and run ./update.py database'
|
||||||
|
|
Loading…
Reference in a new issue