do not execute pip when not needed
This commit is contained in:
10
install.py
10
install.py
@ -173,7 +173,8 @@ def frappy(cfg=None, port=None, requirements='', **kwds):
|
|||||||
if not cfg:
|
if not cfg:
|
||||||
return None
|
return None
|
||||||
req = pip_requirements['l_samenv']
|
req = pip_requirements['l_samenv']
|
||||||
req[cfg] = '\n'.join(requirements.split(','))
|
if requirements:
|
||||||
|
req[cfg] = '\n'.join(requirements.split(','))
|
||||||
if port:
|
if port:
|
||||||
cfg = '-p %s %s' % (port, cfg)
|
cfg = '-p %s %s' % (port, cfg)
|
||||||
with open('/home/l_samenv/frappy/requirements.txt') as f:
|
with open('/home/l_samenv/frappy/requirements.txt') as f:
|
||||||
@ -229,6 +230,8 @@ def display(**opts):
|
|||||||
|
|
||||||
def pip():
|
def pip():
|
||||||
for user, requirements in pip_requirements.items():
|
for user, requirements in pip_requirements.items():
|
||||||
|
if not requirements:
|
||||||
|
continue
|
||||||
if user == 'root':
|
if user == 'root':
|
||||||
tmpname = '/root/pip_requirements.tmp'
|
tmpname = '/root/pip_requirements.tmp'
|
||||||
pipcmd = ['sudo pip3 install -r', tmpname]
|
pipcmd = ['sudo pip3 install -r', tmpname]
|
||||||
@ -238,15 +241,14 @@ def pip():
|
|||||||
filename = tmpname.replace('.tmp', '.txt')
|
filename = tmpname.replace('.tmp', '.txt')
|
||||||
content = ''.join('# --- for %s ---\n%s\n' % kv for kv in requirements.items())
|
content = ''.join('# --- for %s ---\n%s\n' % kv for kv in requirements.items())
|
||||||
if content:
|
if content:
|
||||||
if write_when_new(filename, content, True):
|
if write_when_new(filename, content, user=='root'):
|
||||||
if doit:
|
if doit:
|
||||||
os.rename(filename, tmpname)
|
os.rename(filename, tmpname)
|
||||||
if os.system(' '.join(pipcmd)) == 0:
|
if os.system(' '.join(pipcmd)) == 0:
|
||||||
os.rename(tmpname, filename)
|
os.rename(tmpname, filename)
|
||||||
else:
|
else:
|
||||||
os.remove(tmpname)
|
os.remove(tmpname)
|
||||||
# unix_cmd(pipcmd, doit, stdout=None)
|
show.dirty = True
|
||||||
show.dirty = True
|
|
||||||
|
|
||||||
|
|
||||||
SERVICES = dict(router=router, frappy=frappy, display=display)
|
SERVICES = dict(router=router, frappy=frappy, display=display)
|
||||||
|
Reference in New Issue
Block a user