close_fds=True by default
This commit is contained in:
parent
0bd359f89d
commit
2cd77e07a2
5 changed files with 13 additions and 14 deletions
|
@ -23,7 +23,7 @@ def selectFolder(data):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
cmd = ['./ctl', 'ui', 'folder']
|
cmd = ['./ctl', 'ui', 'folder']
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True)
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
path = stdout.decode('utf-8').strip()
|
path = stdout.decode('utf-8').strip()
|
||||||
return {
|
return {
|
||||||
|
@ -105,7 +105,6 @@ def restart(data):
|
||||||
'''
|
'''
|
||||||
restart (and upgrade if upgrades are available)
|
restart (and upgrade if upgrades are available)
|
||||||
'''
|
'''
|
||||||
#subprocess.Popen(['./ctl', 'restart'], preexec_fn=os.setpgrp, close_fds=True)
|
|
||||||
subprocess.Popen(['./ctl', 'restart'], close_fds=True)
|
subprocess.Popen(['./ctl', 'restart'], close_fds=True)
|
||||||
return {}
|
return {}
|
||||||
actions.register(restart, cache=False)
|
actions.register(restart, cache=False)
|
||||||
|
|
|
@ -12,12 +12,12 @@ import settings
|
||||||
root_dir = dirname(settings.base_dir)
|
root_dir = dirname(settings.base_dir)
|
||||||
|
|
||||||
def run(*cmd):
|
def run(*cmd):
|
||||||
p = subprocess.Popen(cmd)
|
p = subprocess.Popen(cmd, close_fds=True)
|
||||||
p.wait()
|
p.wait()
|
||||||
return p.returncode
|
return p.returncode
|
||||||
|
|
||||||
def get(*cmd):
|
def get(*cmd):
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
|
||||||
stdout, error = p.communicate()
|
stdout, error = p.communicate()
|
||||||
return stdout
|
return stdout
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ def ql_cover(pdf):
|
||||||
tmp,
|
tmp,
|
||||||
pdf
|
pdf
|
||||||
]
|
]
|
||||||
p = subprocess.Popen(cmd)
|
p = subprocess.Popen(cmd, close_fds=True)
|
||||||
p.wait()
|
p.wait()
|
||||||
image = glob('%s/*' % tmp)
|
image = glob('%s/*' % tmp)
|
||||||
if image:
|
if image:
|
||||||
|
@ -58,7 +58,7 @@ def page(pdf, page):
|
||||||
'-scale-to', '1024', '-cropbox',
|
'-scale-to', '1024', '-cropbox',
|
||||||
os.path.join(tmp, 'page')
|
os.path.join(tmp, 'page')
|
||||||
]
|
]
|
||||||
p = subprocess.Popen(cmd)
|
p = subprocess.Popen(cmd, close_fds=True)
|
||||||
p.wait()
|
p.wait()
|
||||||
image = glob('%s/*' % tmp)
|
image = glob('%s/*' % tmp)
|
||||||
if image:
|
if image:
|
||||||
|
@ -87,7 +87,7 @@ def page(pdf, page):
|
||||||
'-sOutputFile=%s' % image,
|
'-sOutputFile=%s' % image,
|
||||||
pdf
|
pdf
|
||||||
]
|
]
|
||||||
p = subprocess.Popen(cmd)
|
p = subprocess.Popen(cmd, close_fds=True)
|
||||||
p.wait()
|
p.wait()
|
||||||
with open(image, 'rb') as fd:
|
with open(image, 'rb') as fd:
|
||||||
data = fd.read()
|
data = fd.read()
|
||||||
|
@ -123,7 +123,7 @@ def info(pdf):
|
||||||
|
|
||||||
'''
|
'''
|
||||||
cmd = ['pdfinfo', pdf]
|
cmd = ['pdfinfo', pdf]
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
for line in stdout.strip().split('\n'):
|
for line in stdout.strip().split('\n'):
|
||||||
parts = line.split(':')
|
parts = line.split(':')
|
||||||
|
@ -168,7 +168,7 @@ def extract_text(pdf):
|
||||||
cmd = ['/usr/bin/mdimport', '-d2', pdf]
|
cmd = ['/usr/bin/mdimport', '-d2', pdf]
|
||||||
else:
|
else:
|
||||||
cmd = ['pdftotext', pdf, '-']
|
cmd = ['pdftotext', pdf, '-']
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
if 'kMDItemTextContent' in stderr:
|
if 'kMDItemTextContent' in stderr:
|
||||||
|
|
|
@ -10,7 +10,7 @@ import subprocess
|
||||||
def cover(path):
|
def cover(path):
|
||||||
image = tempfile.mkstemp('.jpg')[1]
|
image = tempfile.mkstemp('.jpg')[1]
|
||||||
cmd = ['python2', 'static/txt.js/txt.py', '-i', path, '-o', image]
|
cmd = ['python2', 'static/txt.js/txt.py', '-i', path, '-o', image]
|
||||||
p = subprocess.Popen(cmd)
|
p = subprocess.Popen(cmd, close_fds=True)
|
||||||
p.wait()
|
p.wait()
|
||||||
with open(image, 'rb') as fd:
|
with open(image, 'rb') as fd:
|
||||||
data = fd.read()
|
data = fd.read()
|
||||||
|
|
|
@ -135,7 +135,7 @@ def get_interface():
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
#cmd = ['/usr/sbin/netstat', '-rn']
|
#cmd = ['/usr/sbin/netstat', '-rn']
|
||||||
cmd = ['/sbin/route', '-n', 'get', 'default']
|
cmd = ['/sbin/route', '-n', 'get', 'default']
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True)
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
interface = [[p.strip() for p in s.split(':', 1)] for s in stdout.strip().split('\n') if 'interface' in s]
|
interface = [[p.strip() for p in s.split(':', 1)] for s in stdout.strip().split('\n') if 'interface' in s]
|
||||||
if interface:
|
if interface:
|
||||||
|
@ -148,21 +148,21 @@ def get_local_ipv4():
|
||||||
ip = None
|
ip = None
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
cmd = ['/sbin/route', '-n', 'get', 'default']
|
cmd = ['/sbin/route', '-n', 'get', 'default']
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True)
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
interface = [[p.strip() for p in s.split(':', 1)]
|
interface = [[p.strip() for p in s.split(':', 1)]
|
||||||
for s in stdout.strip().split('\n') if 'interface' in s]
|
for s in stdout.strip().split('\n') if 'interface' in s]
|
||||||
if interface:
|
if interface:
|
||||||
interface = interface[0][1]
|
interface = interface[0][1]
|
||||||
cmd = ['ifconfig', interface]
|
cmd = ['ifconfig', interface]
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True)
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
ips = [l for l in stdout.split('\n') if 'inet ' in l]
|
ips = [l for l in stdout.split('\n') if 'inet ' in l]
|
||||||
if ips:
|
if ips:
|
||||||
ip = ips[0].strip().split(' ')[1]
|
ip = ips[0].strip().split(' ')[1]
|
||||||
else:
|
else:
|
||||||
cmd = ['ip', 'route', 'show']
|
cmd = ['ip', 'route', 'show']
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True)
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
local = [l for l in stdout.split('\n') if 'default' in l]
|
local = [l for l in stdout.split('\n') if 'default' in l]
|
||||||
if local:
|
if local:
|
||||||
|
|
Loading…
Reference in a new issue