def main(): pid_file = 'av-control.pid' fp = open(pid_file, 'w') try: fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError: # another instance is running print "av-control is already running." sys.exit(1) logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=logging.INFO) app = QApplication(sys.argv) parser = argparse.ArgumentParser() parser.add_argument("-f", "--fullscreen", help="Run in fullscreen mode and hide the mouse cursor", action="store_true") parser.add_argument("-c", help="Specify the controller ID to connect to", metavar="CONTROLLERID", default="") args = parser.parse_args() try: ssf = QFile(":/stylesheet") ssf.open(QFile.ReadOnly) styleSheet = str(ssf.readAll()) app.setStyleSheet(styleSheet) except IOError: # never mind logging.warn("Cannot find stylesheet, using default system styles.") try: controller = Controller.fromPyro(args.c) myapp = MainWindow(controller) client = AvControlClient(myapp) client.setDaemon(True) client.start() client.started.wait() atexit.register(lambda: controller.unregisterClient(client.uri)) controller.registerClient(client.uri) if args.fullscreen: QApplication.setOverrideCursor(Qt.BlankCursor) myapp.showFullScreen() else: myapp.show() sys.exit(app.exec_()) except VersionMismatchError as e: Dialogs.errorBox(str(e))
def main(): pid_file = 'av-control.pid' fp = open(pid_file, 'w') try: fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError: # another instance is running print "av-control is already running." sys.exit(1) logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=logging.INFO) app = QApplication(sys.argv) parser = argparse.ArgumentParser() parser.add_argument("-f", "--fullscreen", help="Run in fullscreen mode and hide the mouse cursor", action="store_true") parser.add_argument("-c", help="Specify the controller ID to connect to", metavar="CONTROLLERID", default="") parser.add_argument("-j", "--joystick", help="Path to joystick device to use for camera control") args = parser.parse_args() try: ssf = QFile(":/stylesheet") ssf.open(QFile.ReadOnly) styleSheet = str(ssf.readAll()) app.setStyleSheet(styleSheet) except IOError: # never mind logging.warn("Cannot find stylesheet, using default system styles.") try: controller = Controller.fromPyro(args.c) js = None joystickDevice = args.joystick print args try: if args.joystick: if os.path.exists(joystickDevice): logging.info("Configuring joystick {}".format(joystickDevice)) js = Joystick(joystickDevice) js.start() else: logging.error("Specified joystick device {} does not exist!".format(joystickDevice)) except IOError: logging.exception("Unable to configure joystick") pass jsa = SensitivityPrefsCameraJoystickAdapter(js) jsa.start() myapp = MainWindow(controller, jsa) client = AvControlClient(myapp) client.setDaemon(True) client.start() client.started.wait() atexit.register(lambda: controller.unregisterClient(client.uri)) controller.registerClient(client.uri) if args.fullscreen: QApplication.setOverrideCursor(Qt.BlankCursor) myapp.showFullScreen() else: myapp.show() sys.exit(app.exec_()) except VersionMismatchError as e: Dialogs.errorBox(str(e))
def errorBox(self, text): Dialogs.errorBox(text)
def main(): pid_file = 'av-control.pid' fp = open(pid_file, 'w') try: fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError: # another instance is running print "av-control is already running." sys.exit(1) logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=logging.INFO) app = QApplication(sys.argv) parser = argparse.ArgumentParser() parser.add_argument( "-f", "--fullscreen", help="Run in fullscreen mode and hide the mouse cursor", action="store_true") parser.add_argument("-c", help="Specify the controller ID to connect to", metavar="CONTROLLERID", default="") parser.add_argument( "-j", "--joystick", help="Path to joystick device to use for camera control") args = parser.parse_args() try: ssf = QFile(":/stylesheet") ssf.open(QFile.ReadOnly) styleSheet = str(ssf.readAll()) app.setStyleSheet(styleSheet) except IOError: # never mind logging.warn("Cannot find stylesheet, using default system styles.") try: controller = Controller.fromPyro(args.c) js = None joystickDevice = args.joystick print args try: if args.joystick: if os.path.exists(joystickDevice): logging.info( "Configuring joystick {}".format(joystickDevice)) js = Joystick(joystickDevice) js.start() else: logging.error( "Specified joystick device {} does not exist!".format( joystickDevice)) except IOError: logging.exception("Unable to configure joystick") pass jsa = SensitivityPrefsCameraJoystickAdapter(js) jsa.start() myapp = MainWindow(controller, jsa) client = AvControlClient(myapp) client.setDaemon(True) client.start() client.started.wait() atexit.register(lambda: controller.unregisterClient(client.uri)) controller.registerClient(client.uri) if args.fullscreen: QApplication.setOverrideCursor(Qt.BlankCursor) myapp.showFullScreen() else: myapp.show() sys.exit(app.exec_()) except VersionMismatchError as e: Dialogs.errorBox(str(e))