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
91
update.py
91
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']
|
||||||
|
if 'revision' in repos[repo]:
|
||||||
|
if int(revno) < repos[repo]['revision']:
|
||||||
|
run('bzr', 'pull', url, '-r', '%s' % repos[repo]['revision'])
|
||||||
else:
|
else:
|
||||||
os.chdir(join(base, 'static'))
|
run('bzr', 'pull', url)
|
||||||
run('bzr', 'branch', repos['oxjs'])
|
revno = get('bzr', 'revno')
|
||||||
|
new += revno
|
||||||
|
else:
|
||||||
|
os.chdir(os.path.dirname(path))
|
||||||
|
cmd = ['bzr', 'branch', repos[repo]['url']]
|
||||||
|
if 'revision' in repos[repo]:
|
||||||
|
cmd += ['-r', '%s' % repos[repo]['revision']]
|
||||||
|
run(*cmd)
|
||||||
|
setup = os.path.join(base, repos[repo]['path'], 'setup.py')
|
||||||
|
if repo in ('python-ox', 'oxtimelines') and os.path.exists(setup):
|
||||||
|
os.chdir(os.path.dirname(setup))
|
||||||
|
run(os.path.join(base, 'bin', 'python'), 'setup.py', 'develop')
|
||||||
new += '+'
|
new += '+'
|
||||||
|
|
||||||
if exists(join(base, 'src', 'python-ox')):
|
|
||||||
os.chdir(join(base, 'src', 'python-ox'))
|
|
||||||
current += get('bzr', 'revno')
|
|
||||||
run('bzr', 'pull', repos['python-ox'])
|
|
||||||
new += get('bzr', 'revno')
|
|
||||||
|
|
||||||
if exists(join(base, 'src', 'oxtimelines')):
|
|
||||||
os.chdir(join(base, 'src', 'oxtimelines'))
|
|
||||||
current += get('bzr', 'revno')
|
|
||||||
run('bzr', 'pull', repos['oxtimelines'])
|
|
||||||
new += get('bzr', 'revno')
|
|
||||||
else:
|
|
||||||
print "oxtimelines is missing. please run:\n\n\tcd %s\n\tpip -E . install -r requirements.txt\n" % (base)
|
|
||||||
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