def execute(parser, args, pycam): # try to change the process name pycam.Utils.setproctitle("pycam") if args.trace: log.setLevel(logging.DEBUG // 2) elif args.debug: log.setLevel(logging.DEBUG) elif args.quiet: log.setLevel(logging.WARNING) # disable the progress bar args.progress = "none" # silence all warnings warnings.filterwarnings("ignore") else: log.setLevel(logging.INFO) # check if server-auth-key is given -> this is mandatory for server mode if (args.enable_server or args.start_server) and not args.server_authkey: parser.error( "You need to supply a shared secret for server mode. This is supposed to prevent you " "from exposing your host to remote access without authentication.\nPlease add the " "'--server-auth-key' argument followed by a shared secret password." ) return EXIT_CODES["server_without_password"] # initialize multiprocessing try: if args.server_authkey is None: server_auth_key = None else: server_auth_key = args.server_authkey.encode("utf-8") if args.start_server: pycam.Utils.threading.init_threading( args.parallel_processes, remote=args.remote_server, run_server=True, server_credentials=server_auth_key) pycam.Utils.threading.cleanup() return EXIT_CODES["ok"] else: pycam.Utils.threading.init_threading( args.parallel_processes, enable_server=args.enable_server, remote=args.remote_server, server_credentials=server_auth_key) except socket.error as err_msg: log.error("Failed to connect to remote server: %s", err_msg) return EXIT_CODES["connection_error"] except AuthenticationError as err_msg: log.error("The remote server rejected your authentication key: %s", err_msg) return EXIT_CODES["connection_error"] try: show_gui() except InitializationError as exc: EmergencyDialog("PyCAM startup failure", str(exc)) return EXIT_CODES["requirements"]
def execute(parser, opts, args, pycam): # try to change the process name pycam.Utils.setproctitle("pycam") if len(args) > 0: inputfile = pycam.Utils.URIHandler(args[0]) else: inputfile = None if opts.debug: log.setLevel(logging.DEBUG) elif opts.quiet: log.setLevel(logging.WARNING) # disable the progress bar opts.progress = "none" # silence all warnings warnings.filterwarnings("ignore") else: # silence gtk warnings try: import gtk warnings.filterwarnings("ignore", category=gtk.Warning) except ImportError: pass # show version and exit if opts.show_version: if opts.quiet: # print only the bare version number print VERSION else: text = '''PyCAM %s Copyright (C) 2008-2010 Lode Leroy Copyright (C) 2010-2011 Lars Kruse License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.''' % VERSION print text return EXIT_CODES["ok"] if not opts.disable_psyco: try: import psyco psyco.full() log.info("Psyco enabled") except ImportError: log.info("Psyco is not available (performance will probably " \ + "suffer slightly)") else: log.info("Psyco was disabled via the commandline") # check if server-auth-key is given -> this is mandatory for server mode if (opts.enable_server or opts.start_server) and not opts.server_authkey: parser.error("You need to supply a shared secret for server mode. " \ + "This is supposed to prevent you from exposing your host " \ + "to remote access without authentication.\n" \ + "Please add the '--server-auth-key' argument followed by " \ + "a shared secret password.") return EXIT_CODES["server_without_password"] # initialize multiprocessing try: if opts.start_server: pycam.Utils.threading.init_threading( opts.parallel_processes, remote=opts.remote_server, run_server=True, server_credentials=opts.server_authkey) pycam.Utils.threading.cleanup() return EXIT_CODES["ok"] else: pycam.Utils.threading.init_threading( opts.parallel_processes, enable_server=opts.enable_server, remote=opts.remote_server, server_credentials=opts.server_authkey) except socket.error, err_msg: log.error("Failed to connect to remote server: %s" % err_msg) return EXIT_CODES["connection_error"]
def execute(parser, opts, args, pycam): # try to change the process name pycam.Utils.setproctitle("pycam") if opts.trace: log.setLevel(logging.DEBUG / 2) elif opts.debug: log.setLevel(logging.DEBUG) elif opts.quiet: log.setLevel(logging.WARNING) # disable the progress bar opts.progress = "none" # silence all warnings warnings.filterwarnings("ignore") else: # silence gtk warnings try: import gi gi.require_version("Gtk", "3.0") # from gi.repository import Gtk as gtk # warnings.filterwarnings("ignore", category=gtk.Warning) FIXME except ImportError: pass # show version and exit if opts.show_version: if opts.quiet: # print only the bare version number print(VERSION) else: text = """PyCAM %s Copyright (C) 2008-2010 Lode Leroy Copyright (C) 2010-2017 Lars Kruse and many other contributors License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.""" % VERSION print(text) return EXIT_CODES["ok"] # check if server-auth-key is given -> this is mandatory for server mode if (opts.enable_server or opts.start_server) and not opts.server_authkey: parser.error( "You need to supply a shared secret for server mode. This is supposed to prevent you " "from exposing your host to remote access without authentication.\nPlease add the " "'--server-auth-key' argument followed by a shared secret password." ) return EXIT_CODES["server_without_password"] # initialize multiprocessing try: if opts.start_server: pycam.Utils.threading.init_threading( opts.parallel_processes, remote=opts.remote_server, run_server=True, server_credentials=opts.server_authkey) pycam.Utils.threading.cleanup() return EXIT_CODES["ok"] else: pycam.Utils.threading.init_threading( opts.parallel_processes, enable_server=opts.enable_server, remote=opts.remote_server, server_credentials=opts.server_authkey) except socket.error as err_msg: log.error("Failed to connect to remote server: %s", err_msg) return EXIT_CODES["connection_error"] except AuthenticationError as err_msg: log.error("The remote server rejected your authentication key: %s", err_msg) return EXIT_CODES["connection_error"] show_gui()
def execute(parser, opts, args, pycam): # try to change the process name pycam.Utils.setproctitle("pycam") if len(args) > 0: inputfile = pycam.Utils.URIHandler(args[0]) else: inputfile = None if opts.debug: log.setLevel(logging.DEBUG) elif opts.quiet: log.setLevel(logging.WARNING) # disable the progress bar opts.progress = "none" # silence all warnings warnings.filterwarnings("ignore") else: # silence gtk warnings try: import gtk warnings.filterwarnings("ignore", category=gtk.Warning) except ImportError: pass # show version and exit if opts.show_version: if opts.quiet: # print only the bare version number print VERSION else: text = '''PyCAM %s Copyright (C) 2008-2010 Lode Leroy Copyright (C) 2010-2011 Lars Kruse License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.''' % VERSION print text return EXIT_CODES["ok"] if not opts.disable_psyco: try: import psyco psyco.full() log.info("Psyco enabled") except ImportError: log.info("Psyco is not available (performance will probably " \ + "suffer slightly)") else: log.info("Psyco was disabled via the commandline") # check if server-auth-key is given -> this is mandatory for server mode if (opts.enable_server or opts.start_server) and not opts.server_authkey: parser.error("You need to supply a shared secret for server mode. " \ + "This is supposed to prevent you from exposing your host " \ + "to remote access without authentication.\n" \ + "Please add the '--server-auth-key' argument followed by " \ + "a shared secret password.") return EXIT_CODES["server_without_password"] # initialize multiprocessing try: if opts.start_server: pycam.Utils.threading.init_threading(opts.parallel_processes, remote=opts.remote_server, run_server=True, server_credentials=opts.server_authkey) pycam.Utils.threading.cleanup() return EXIT_CODES["ok"] else: pycam.Utils.threading.init_threading(opts.parallel_processes, enable_server=opts.enable_server, remote=opts.remote_server, server_credentials=opts.server_authkey) except socket.error, err_msg: log.error("Failed to connect to remote server: %s" % err_msg) return EXIT_CODES["connection_error"]