mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-27 03:14:45 +00:00
Improve import handling and autoconf
This commit is contained in:
parent
1c0739641f
commit
2370d4e742
1 changed files with 16 additions and 11 deletions
|
@ -43,17 +43,21 @@
|
||||||
##########################################
|
##########################################
|
||||||
|
|
||||||
|
|
||||||
import commands
|
|
||||||
from deluge.log import setupLogger
|
|
||||||
from deluge.ui.client import client
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import string
|
import string
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
try:
|
||||||
|
from deluge.log import setupLogger
|
||||||
|
from deluge.ui.client import client
|
||||||
from twisted.internet import reactor, defer
|
from twisted.internet import reactor, defer
|
||||||
|
|
||||||
|
|
||||||
setupLogger()
|
setupLogger()
|
||||||
|
except (ImportError, NameError):
|
||||||
|
successful_import = False
|
||||||
|
else:
|
||||||
|
successful_import = True
|
||||||
|
|
||||||
|
|
||||||
plugin_version = "1.0.0"
|
plugin_version = "1.0.0"
|
||||||
|
|
||||||
|
@ -308,6 +312,10 @@ def print_config(mode):
|
||||||
|
|
||||||
|
|
||||||
def fetch_info(mode):
|
def fetch_info(mode):
|
||||||
|
if not successful_import:
|
||||||
|
print('Missing imports, cannot run !')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
log.debug("Launching tests")
|
log.debug("Launching tests")
|
||||||
c = StatClient(conf, mode)
|
c = StatClient(conf, mode)
|
||||||
c.fetch_info()
|
c.fetch_info()
|
||||||
|
@ -320,13 +328,10 @@ if len(sys.argv) > 1:
|
||||||
print_config(get_mode())
|
print_config(get_mode())
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
elif action == "autoconf":
|
elif action == "autoconf":
|
||||||
status, output = commands.getstatusoutput('which deluged')
|
if not successful_import:
|
||||||
if status == 0:
|
print('no (required modules not found)')
|
||||||
print('yes')
|
|
||||||
sys.exit(0)
|
|
||||||
else:
|
|
||||||
print('no (deluged not found)')
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
print('yes')
|
||||||
elif action == "suggest":
|
elif action == "suggest":
|
||||||
for mode in modes:
|
for mode in modes:
|
||||||
print(mode)
|
print(mode)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue