Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if cmd == 'status':
return generateDaemonStatusButton()
elif cmd == 'start':
subprocess.Popen(['ipfs', 'daemon'])
# retString = 'Failed to start IPFS daemon'
# if 'Daemon is ready' in check_output():
# retString = 'IPFS daemon started'
return Response('IPFS daemon starting...')
elif cmd == 'stop':
try:
installedIPFSVersion = IPFS_API.version()['Version']
if ipwbConfig.compareVersions(installedIPFSVersion, '0.4.10') < 0:
raise UnsupportedIPFSVersions()
IPFS_API.shutdown()
except (subprocess.CalledProcessError, UnsupportedIPFSVersions) as e:
# go-ipfs < 0.4.10
if os.name == 'nt':
subprocess.call(['taskkill', '/im', 'ipfs.exe', '/F'])
else:
subprocess.call(['killall', 'ipfs'])
return Response('IPFS daemon stopping...')
else:
print('ERROR, bad command sent to daemon API!')
print(cmd)
return Response('bad command!')
def commandDaemon(cmd):
global IPFS_API
if cmd == 'status':
return generateDaemonStatusButton()
elif cmd == 'start':
subprocess.Popen(['ipfs', 'daemon'])
return Response('IPFS daemon starting...')
elif cmd == 'stop':
try:
installedIPFSVersion = IPFS_API.version()['Version']
if ipwbUtils.compareVersions(installedIPFSVersion, '0.4.10') < 0:
raise UnsupportedIPFSVersions()
IPFS_API.shutdown()
except (subprocess.CalledProcessError, UnsupportedIPFSVersions) as e:
if os.name != 'nt': # Big hammer
subprocess.call(['killall', 'ipfs'])
else:
subprocess.call(['taskkill', '/im', 'ipfs.exe', '/F'])
return Response('IPFS daemon stopping...')
elif cmd == 'webuilink':
return Response(ipwbUtils.getIPFSAPIHostAndPort() + '/webui')
else:
print('ERROR, bad command sent to daemon API!')
print(cmd)
return Response('bad command!')
def commandDaemon(cmd):
global IPFS_API
if cmd == 'status':
return generateDaemonStatusButton()
elif cmd == 'start':
subprocess.Popen(['ipfs', 'daemon'])
# retString = 'Failed to start IPFS daemon'
# if 'Daemon is ready' in check_output():
# retString = 'IPFS daemon started'
return Response('IPFS daemon starting...')
elif cmd == 'stop':
try:
installedIPFSVersion = IPFS_API.version()['Version']
if ipwbConfig.compareVersions(installedIPFSVersion, '0.4.10') < 0:
raise UnsupportedIPFSVersions()
IPFS_API.shutdown()
except (subprocess.CalledProcessError, UnsupportedIPFSVersions) as e:
# go-ipfs < 0.4.10
if os.name == 'nt':
subprocess.call(['taskkill', '/im', 'ipfs.exe', '/F'])
else:
subprocess.call(['killall', 'ipfs'])
return Response('IPFS daemon stopping...')
else:
print('ERROR, bad command sent to daemon API!')
print(cmd)
return Response('bad command!')