当前位置: 首页>>代码示例>>Python>>正文


Python os.EX_USAGE属性代码示例

本文整理汇总了Python中os.EX_USAGE属性的典型用法代码示例。如果您正苦于以下问题:Python os.EX_USAGE属性的具体用法?Python os.EX_USAGE怎么用?Python os.EX_USAGE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在os的用法示例。


在下文中一共展示了os.EX_USAGE属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_USAGE [as 别名]
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 
开发者ID:sixty-north,项目名称:segpy,代码行数:24,代码来源:report.py

示例2: main

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_USAGE [as 别名]
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 
开发者ID:sixty-north,项目名称:segpy,代码行数:26,代码来源:scale_source_coords.py

示例3: main

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_USAGE [as 别名]
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 
开发者ID:sixty-north,项目名称:segpy,代码行数:25,代码来源:loadsave.py

示例4: main

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_USAGE [as 别名]
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 
开发者ID:sixty-north,项目名称:segpy,代码行数:24,代码来源:timed_reader.py

示例5: main

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_USAGE [as 别名]
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 
开发者ID:sixty-north,项目名称:segpy,代码行数:36,代码来源:convert_sample_type.py

示例6: common_option_handler

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_USAGE [as 别名]
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) 
开发者ID:sixty-north,项目名称:segpy,代码行数:13,代码来源:cli.py

示例7: edit

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_USAGE [as 别名]
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
    ) 
开发者ID:nmstate,项目名称:nmstate,代码行数:28,代码来源:nmstatectl.py

示例8: main

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_USAGE [as 别名]
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) 
开发者ID:zzerrg,项目名称:gmfwtools,代码行数:31,代码来源:gm_app_fw.py

示例9: err_no_in_file

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_USAGE [as 别名]
def err_no_in_file():
    print("Error: No in_file given! Use -h for help.")
    sys.exit(os.EX_USAGE) 
开发者ID:Stewori,项目名称:pytypes,代码行数:5,代码来源:stubfile_2_converter.py


注:本文中的os.EX_USAGE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。