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
|
WantedBy = multi-user.target
|
||||||
"""
|
"""
|
||||||
pip_requirements = {
|
pip_requirements = {
|
||||||
'l_samenv': [],
|
'l_samenv': {},
|
||||||
'root': []
|
'root': {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def frappy(cfg=None, port=None, requirements='', **kwds):
|
def frappy(cfg=None, port=None, requirements='', **kwds):
|
||||||
if not cfg:
|
if not cfg:
|
||||||
return None
|
return None
|
||||||
|
req = pip_requirements['l_samenv']
|
||||||
|
req[cfg] = '\n'.join(requirements.split(','))
|
||||||
if port:
|
if port:
|
||||||
cfg = '-p %s %s' % (port, cfg)
|
cfg = '-p %s %s' % (port, cfg)
|
||||||
pip_requirements['l_samenv'].extend(requirements.split(','))
|
|
||||||
with open('/home/l_samenv/frappy/requirements.txt') as f:
|
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
|
return FRAPPY_TEMPLATE % cfg
|
||||||
|
|
||||||
|
|
||||||
def router(**opts):
|
def router(**opts):
|
||||||
if not opts:
|
if not opts:
|
||||||
return None
|
return None
|
||||||
with open('/root/aputools/requirements.txt') as f:
|
try:
|
||||||
pip_requirements['root'].extend(f.read().split('\n'))
|
with open('/root/aputools/requirements.txt') as f:
|
||||||
|
pip_requirements['root']['aputools'] = f.read()
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
return ROUTER_TEMPLATE
|
return ROUTER_TEMPLATE
|
||||||
|
|
||||||
|
|
||||||
def pip():
|
def pip():
|
||||||
for user, requirements in pip_requirements.items():
|
for user, requirements in pip_requirements.items():
|
||||||
if user == 'root':
|
if user == 'root':
|
||||||
filename = join('/home', user, 'pip_requirements.txt')
|
filename = join('/root', 'pip_requirements.txt')
|
||||||
pipcmd = 'pip3 install -r %s' % filename
|
pipcmd = 'pip3 install -r %s' % filename
|
||||||
else:
|
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)
|
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)
|
unix_cmd(pipcmd)
|
||||||
|
show.dirty = True
|
||||||
|
|
||||||
|
|
||||||
SERVICES = dict(router=router, frappy=frappy)
|
SERVICES = dict(router=router, frappy=frappy)
|
||||||
@ -390,9 +396,10 @@ def handle_config():
|
|||||||
else:
|
else:
|
||||||
if not active:
|
if not active:
|
||||||
actions.add('restart')
|
actions.add('restart')
|
||||||
if not enabled
|
if not enabled:
|
||||||
actions.add('enable')
|
actions.add('enable')
|
||||||
if write_when_new('/etc/systemd/system/%s.service' % service, template):
|
if write_when_new('/etc/systemd/system/%s.service' % service, template):
|
||||||
|
show.dirty = True
|
||||||
reload_systemd = True
|
reload_systemd = True
|
||||||
if 'enable' in actions:
|
if 'enable' in actions:
|
||||||
actions.add('restart')
|
actions.add('restart')
|
||||||
|
@ -16,4 +16,3 @@ enp4s0=192.168.127.4/24
|
|||||||
cfg=sim_uniax
|
cfg=sim_uniax
|
||||||
port=5000
|
port=5000
|
||||||
requirements=numpy,scipy
|
requirements=numpy,scipy
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user