mirror of https://github.com/CIRCL/lookyloo
new: Add self check in update script.
parent
c0ec0d7a50
commit
98eac69d1f
|
@ -6,6 +6,7 @@ import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
import shlex
|
import shlex
|
||||||
import sys
|
import sys
|
||||||
|
import hashlib
|
||||||
|
|
||||||
from lookyloo.helpers import get_homedir
|
from lookyloo.helpers import get_homedir
|
||||||
|
|
||||||
|
@ -13,6 +14,12 @@ logging.basicConfig(format='%(asctime)s %(name)s %(levelname)s:%(message)s',
|
||||||
level=logging.INFO, datefmt='%I:%M:%S')
|
level=logging.INFO, datefmt='%I:%M:%S')
|
||||||
|
|
||||||
|
|
||||||
|
def compute_hash_self():
|
||||||
|
m = hashlib.sha256()
|
||||||
|
with (get_homedir() / 'bin' / 'update.py').open('rb') as f:
|
||||||
|
return m.update(f.read())
|
||||||
|
|
||||||
|
|
||||||
def keep_going(ignore=False):
|
def keep_going(ignore=False):
|
||||||
if ignore:
|
if ignore:
|
||||||
return
|
return
|
||||||
|
@ -52,11 +59,17 @@ def main():
|
||||||
parser.add_argument('--yes', default=False, action='store_true', help='Run all commands without asking.')
|
parser.add_argument('--yes', default=False, action='store_true', help='Run all commands without asking.')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
check_poetry_version()
|
old_hash = compute_hash_self()
|
||||||
|
|
||||||
print('* Update repository.')
|
print('* Update repository.')
|
||||||
keep_going(args.yes)
|
keep_going(args.yes)
|
||||||
run_command('git pull')
|
run_command('git pull')
|
||||||
|
new_hash = compute_hash_self()
|
||||||
|
if old_hash != new_hash:
|
||||||
|
print('Update script changed, please do "poetry run update"')
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
check_poetry_version()
|
||||||
|
|
||||||
print('* Install/update dependencies.')
|
print('* Install/update dependencies.')
|
||||||
keep_going(args.yes)
|
keep_going(args.yes)
|
||||||
|
|
Loading…
Reference in New Issue