Example #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()
Example #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)
Example #3
0
                            "MDROID_HOST not found in config file, not using MDroid API."
                        )

                    # Setup device
                    if "PYBUS_DEVICE" in data["MDROID"]:
                        devPath = data["MDROID"]["PYBUS_DEVICE"]
                        core.DEVPATH = data["MDROID"]["PYBUS_DEVICE"]
                    else:
                        logging.debug(
                            "PYBUS_DEVICE not found in config file, using defaults."
                        )

        except IOError as e:
            logging.error("Failed to open settings file:" + args.settings_file)
            logging.error(e)
    else:
        logging.error("Could not load settings from file" +
                      str(args.settings_file))

# Make requests a little quieter
logging.getLogger("requests").setLevel(logging.ERROR)

try:
    core.initialize(config)
    core.run()
except Exception:
    logging.error("Caught unexpected exception:\n{}".format(
        traceback.format_exc()))
    logging.critical("And I'm dead.")
    sys.exit(0)
Example #4
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)