fix errors in requiements handling
This commit is contained in:
27
install.py
27
install.py
@ -67,40 +67,46 @@ ExecStart = /usr/bin/python3 /home/l_samenv/frappy/bin/secop-server %s
|
||||
WantedBy = multi-user.target
|
||||
"""
|
||||
pip_requirements = {
|
||||
'l_samenv': [],
|
||||
'root': []
|
||||
'l_samenv': {},
|
||||
'root': {}
|
||||
}
|
||||
|
||||
|
||||
def frappy(cfg=None, port=None, requirements='', **kwds):
|
||||
if not cfg:
|
||||
return None
|
||||
req = pip_requirements['l_samenv']
|
||||
req[cfg] = '\n'.join(requirements.split(','))
|
||||
if port:
|
||||
cfg = '-p %s %s' % (port, cfg)
|
||||
pip_requirements['l_samenv'].extend(requirements.split(','))
|
||||
with open('/home/l_samenv/frappy/requirements.txt') as f:
|
||||
pip_requirements['l_samenv'].extend(f.read().split('\n'))
|
||||
req['frappy main'] = f.read()
|
||||
return FRAPPY_TEMPLATE % cfg
|
||||
|
||||
|
||||
def router(**opts):
|
||||
if not opts:
|
||||
return None
|
||||
with open('/root/aputools/requirements.txt') as f:
|
||||
pip_requirements['root'].extend(f.read().split('\n'))
|
||||
try:
|
||||
with open('/root/aputools/requirements.txt') as f:
|
||||
pip_requirements['root']['aputools'] = f.read()
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
return ROUTER_TEMPLATE
|
||||
|
||||
|
||||
def pip():
|
||||
for user, requirements in pip_requirements.items():
|
||||
if user == 'root':
|
||||
filename = join('/home', user, 'pip_requirements.txt')
|
||||
filename = join('/root', 'pip_requirements.txt')
|
||||
pipcmd = 'pip3 install -r %s' % filename
|
||||
else:
|
||||
filename = join('/root', 'pip_requirements.txt')
|
||||
filename = join('/home', user, 'pip_requirements.txt')
|
||||
pipcmd = 'sudo --user %s pip3 install --user -r %s' % (user, filename)
|
||||
if write_when_new(filename, '\n'.join(requirements)):
|
||||
content = ''.join('# --- for %s ---\n%s\n' % kv for kv in requirements.items())
|
||||
if write_when_new(filename, content):
|
||||
unix_cmd(pipcmd)
|
||||
show.dirty = True
|
||||
|
||||
|
||||
SERVICES = dict(router=router, frappy=frappy)
|
||||
@ -390,9 +396,10 @@ def handle_config():
|
||||
else:
|
||||
if not active:
|
||||
actions.add('restart')
|
||||
if not enabled
|
||||
if not enabled:
|
||||
actions.add('enable')
|
||||
if write_when_new('/etc/systemd/system/%s.service' % service, template):
|
||||
show.dirty = True
|
||||
reload_systemd = True
|
||||
if 'enable' in actions:
|
||||
actions.add('restart')
|
||||
|
@ -16,4 +16,3 @@ enp4s0=192.168.127.4/24
|
||||
cfg=sim_uniax
|
||||
port=5000
|
||||
requirements=numpy,scipy
|
||||
|
||||
|
Reference in New Issue
Block a user