Python os.EX_USAGE Examples
The following are 10
code examples of os.EX_USAGE().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
os
, or try the search function
.
Example #1
Source File: report.py From segpy with GNU Affero General Public License v3.0 | 6 votes |
def main(argv=None): if argv is None: argv = sys.argv[1:] try: in_filename = argv[0] except IndexError: print(globals()['__doc__'], file=sys.stderr) return os.EX_USAGE try: report_segy(in_filename) except (FileNotFoundError, IsADirectoryError) as e: print(e, file=sys.stderr) return os.EX_NOINPUT except PermissionError as e: print(e, file=sys.stderr) return os.EX_NOPERM except Exception as e: traceback.print_exception(type(e), e, e.__traceback__, file=sys.stderr) return os.EX_SOFTWARE return os.EX_OK
Example #2
Source File: custom_header.py From segpy with GNU Affero General Public License v3.0 | 6 votes |
def main(argv=None): if argv is None: argv = sys.argv[1:] try: in_filename = argv[0] except IndexError: print(globals()['__doc__'], file=sys.stderr) return os.EX_USAGE try: report_segy(in_filename) except (FileNotFoundError, IsADirectoryError) as e: print(e, file=sys.stderr) return os.EX_NOINPUT except PermissionError as e: print(e, file=sys.stderr) return os.EX_NOPERM except Exception as e: traceback.print_exception(type(e), e, e.__traceback__, file=sys.stderr) return os.EX_SOFTWARE return os.EX_OK
Example #3
Source File: scale_source_coords.py From segpy with GNU Affero General Public License v3.0 | 6 votes |
def main(argv=None): if argv is None: argv = sys.argv[1:] try: scale_factor = float(argv[0]) in_filename = argv[1] out_filename = argv[2] except (ValueError, IndexError): print(globals()['__doc__'], file=sys.stderr) return os.EX_USAGE try: transform(scale_factor, in_filename, out_filename) except (FileNotFoundError, IsADirectoryError) as e: print(e, file=sys.stderr) return os.EX_NOINPUT except PermissionError as e: print(e, file=sys.stderr) return os.EX_NOPERM except Exception as e: traceback.print_exception(type(e), e, e.__traceback__, file=sys.stderr) return os.EX_SOFTWARE return os.EX_OK
Example #4
Source File: loadsave.py From segpy with GNU Affero General Public License v3.0 | 6 votes |
def main(argv=None): if argv is None: argv = sys.argv[1:] try: in_filename = argv[0] out_filename = argv[1] except IndexError: print(globals()['__doc__'], file=sys.stderr) return os.EX_USAGE try: load_save(in_filename, out_filename) except (FileNotFoundError, IsADirectoryError) as e: print(e, file=sys.stderr) return os.EX_NOINPUT except PermissionError as e: print(e, file=sys.stderr) return os.EX_NOPERM except Exception as e: traceback.print_exception(type(e), e, e.__traceback__, file=sys.stderr) return os.EX_SOFTWARE return os.EX_OK
Example #5
Source File: timed_reader.py From segpy with GNU Affero General Public License v3.0 | 6 votes |
def main(argv=None): if argv is None: argv = sys.argv[1:] try: in_filename = argv[0] except IndexError: print(globals()['__doc__'], file=sys.stderr) return os.EX_USAGE try: read_traces(in_filename) except (FileNotFoundError, IsADirectoryError) as e: print(e, file=sys.stderr) return os.EX_NOINPUT except PermissionError as e: print(e, file=sys.stderr) return os.EX_NOPERM except Exception as e: traceback.print_exception(type(e), e, e.__traceback__, file=sys.stderr) return os.EX_SOFTWARE return os.EX_OK
Example #6
Source File: convert_sample_type.py From segpy with GNU Affero General Public License v3.0 | 5 votes |
def main(argv=None): if argv is None: argv = sys.argv[1:] try: data_sample_format = argv[0] in_filename = argv[1] out_filename = argv[2] except (ValueError, IndexError): print(globals()['__doc__'], file=sys.stderr) return os.EX_USAGE if data_sample_format not in SEG_Y_TYPE_DESCRIPTION: print("Accepted data sample formats:") for name, description in SEG_Y_TYPE_DESCRIPTION.items(): print("{} : {}".format(name, description)) return os.EX_USAGE if out_filename == in_filename: print("Output filename {} is the same as input filename".format(out_filename, in_filename)) return os.EX_USAGE try: transform(data_sample_format, in_filename, out_filename) except (FileNotFoundError, IsADirectoryError) as e: print(e, file=sys.stderr) return os.EX_NOINPUT except PermissionError as e: print(e, file=sys.stderr) return os.EX_NOPERM except Exception as e: traceback.print_exception(type(e), e, e.__traceback__, file=sys.stderr) return os.EX_SOFTWARE return os.EX_OK
Example #7
Source File: cli.py From segpy with GNU Affero General Public License v3.0 | 5 votes |
def common_option_handler(config): log_level = config['--log-level'] try: segpy.log.setLevel(log_level) except ValueError: return os.EX_USAGE handler = logging.StreamHandler(stream=sys.stderr) handler.setLevel(log_level) handler.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')) segpy.log.addHandler(handler)
Example #8
Source File: nmstatectl.py From nmstate with GNU Lesser General Public License v2.1 | 5 votes |
def edit(args): state = _filter_state(libnmstate.show(), args.only) if not state[Interface.KEY]: sys.stderr.write("ERROR: No such interface\n") return os.EX_USAGE pretty_state = PrettyState(state) if args.yaml: suffix = ".yaml" txtstate = pretty_state.yaml else: suffix = ".json" txtstate = pretty_state.json new_state = _get_edited_state(txtstate, suffix, args.yaml) if not new_state: return os.EX_DATAERR print("Applying the following state: ") print_state(new_state, use_yaml=args.yaml) libnmstate.apply( new_state, verify_change=args.verify, save_to_disk=args.save_to_disk )
Example #9
Source File: gm_app_fw.py From gmfwtools with Apache License 2.0 | 5 votes |
def main(args): if args.offset: if args.offset[0:2] == '0x': offset = int(args.offset[2:], 16) else: offset = int(args.offset) else: offset = 0 fw = GMAppFirmware(args.fn, offset=offset, verbose=args.debug, fw_version=args.fw_version) if args.verify: is_ok = fw.do_verify() sys.exit(os.EX_OK if is_ok else os.EX_DATAERR) elif args.unpack: fw.do_unpack(args.out_fn, args.exec_fn) elif args.mount: if args.target: fw.do_mount(mpoint=args.target) else: fw.do_mount() elif args.pack: fw.do_pack(args.jffs_image, args.exec_fn) elif args.key: fw.do_key(args.key, False) elif args.keybrute: fw.do_key(None, True) else: print("Usage: one of -v, -u or -p options should be specified") sys.exit(os.EX_USAGE)
Example #10
Source File: stubfile_2_converter.py From pytypes with Apache License 2.0 | 5 votes |
def err_no_in_file(): print("Error: No in_file given! Use -h for help.") sys.exit(os.EX_USAGE)