Exemplo n.º 1
0
def run_pybus():
    try:
        logging.critical("pyBus started !")
        core.initialize()
        core.run()
    except Exception:
        logging.error("Caught unexpected exception:")
        logging.error(traceback.format_exc())
        logging.info("Going to sleep 2 seconds and restart")
        time.sleep(2)
        restart()
Exemplo n.º 2
0
    os.chdir(_startup_cwd)
    os.execv(sys.executable, args)


#####################################
# MAIN
#####################################
parser = createParser()
results = parser.parse_args()
loglevel = results.verbose
core.DEVPATH = results.device
_startup_cwd = os.getcwd()

# Manage Ctrl+C
signal.signal(signal.SIGINT, signal_handler_quit)

configureLogging(loglevel, results.output_file)

try:
    logging.critical("pyBus started !")
    core.initialize()
    core.run()
except Exception:
    logging.error("Caught unexpected exception:")
    logging.error(traceback.format_exc())
    logging.info("Going to sleep 2 seconds and restart")
    time.sleep(2)
    restart()

sys.exit(0)
Exemplo n.º 3
0
  
def createParser():
  parser = argparse.ArgumentParser()
  parser.add_argument('-v', '--verbose', action='count', default=0, help='Increases verbosity of logging.')
  parser.add_argument('--device', action='store', help='Path to iBus USB interface (Bought from reslers.de)')
  return parser

#####################################
# MAIN
#####################################
parser   = createParser()
results  = parser.parse_args()
loglevel = results.verbose
_startup_cwd = os.getcwd()

signal.signal(signal.SIGINT, signal_handler_quit) # Manage Ctrl+C
configureLogging(loglevel)

devPath = sys.argv[1] if (len(sys.argv) > 1) else "/dev/ttyUSB0"
core.DEVPATH = devPath if devPath else "/dev/ttyUSB0"

try:
  core.initialize()
  core.run()
except Exception:
  logging.error("Caught unexpected exception:")
  logging.error(traceback.format_exc())

logging.critical("And I'm dead.")    
sys.exit(0)