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


Python os.EX_SOFTWARE属性代码示例

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


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

示例1: test_dry_run_commands

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_SOFTWARE [as 别名]
def test_dry_run_commands(self):
        unauthorized_ok = [dict(return_codes=[os.EX_OK]),
                           dict(return_codes=[1, os.EX_SOFTWARE], stderr="UnauthorizedOperation")]
        self.call("aegea launch unittest --dry-run --storage /x=512 /y=1024 --ubuntu-linux-ami",
                  shell=True, expect=unauthorized_ok)
        self.call("aegea launch unittest --dry-run --no-verify-ssh-key-pem-file --ubuntu-linux-ami",
                  shell=True, expect=unauthorized_ok)
        self.call("aegea launch unittest --dry-run --spot --no-verify-ssh-key-pem-file --amazon-linux-ami",
                  shell=True, expect=unauthorized_ok)
        self.call("aegea launch unittest --dry-run --duration-hours 1 --no-verify-ssh-key-pem-file --amazon-linux-ami",
                  shell=True, expect=unauthorized_ok)
        self.call(("aegea launch unittest --duration 0.5 --min-mem 6 --cores 2 --dry-run --no-verify --client-token t "
                   "--amazon-linux-ami"),
                  shell=True, expect=unauthorized_ok)
        self.call("aegea build-ami i --dry-run --no-verify-ssh-key-pem-file",
                  shell=True, expect=unauthorized_ok)

        self.call("aegea batch submit --command pwd --dry-run", shell=True)
        self.call("echo pwd > run.sh && aegea batch submit --execute run.sh --dry-run", shell=True)
        self.call("aegea batch submit --wdl '{}' --dry-run".format(__file__.replace(".py", ".wdl")), shell=True)

        self.call("aegea ecs run --command pwd --dry-run", shell=True) 
开发者ID:kislyuk,项目名称:aegea,代码行数:24,代码来源:test.py

示例2: main

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_SOFTWARE [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

示例3: main

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_SOFTWARE [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

示例4: main

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_SOFTWARE [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

示例5: main

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_SOFTWARE [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

示例6: main

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_SOFTWARE [as 别名]
def main():
    config = Configuration()
    debug = False

    try:
        debug = config.bootstrap(environ=os.environ)
        if debug:
            logger.debug("Debug mode enabled.")
        exit(wrapped_main(config))
    except pdb.bdb.BdbQuit:
        logger.info("Graceful exit from debugger.")
    except UserError as e:
        logger.critical("%s", e)
        exit(e.exit_code)
    except Exception:
        logger.exception('Unhandled error:')
        if debug and sys.stdout.isatty():
            logger.debug("Dropping in debugger.")
            pdb.post_mortem(sys.exc_info()[2])
        else:
            logger.error(
                "Please file an issue at "
                "https://github.com/dalibo/ldap2pg/issues with full log.",
            )
    exit(os.EX_SOFTWARE) 
开发者ID:dalibo,项目名称:ldap2pg,代码行数:27,代码来源:script.py

示例7: test_pdb

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_SOFTWARE [as 别名]
def test_pdb(mocker):
    mocker.patch('ldap2pg.script.dictConfig', autospec=True)
    mocker.patch('ldap2pg.script.os.environ', {'DEBUG': '1'})
    isatty = mocker.patch('ldap2pg.script.sys.stdout.isatty')
    isatty.return_value = True
    w = mocker.patch('ldap2pg.script.wrapped_main')
    w.side_effect = Exception()
    pm = mocker.patch('ldap2pg.script.pdb.post_mortem')

    from ldap2pg.script import main

    with pytest.raises(SystemExit) as ei:
        main()

    assert pm.called is True
    assert os.EX_SOFTWARE == ei.value.code 
开发者ID:dalibo,项目名称:ldap2pg,代码行数:18,代码来源:test_script.py

示例8: main

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_SOFTWARE [as 别名]
def main(app_class):
    def main_func():
        parser = concierge.endpoints.cli.create_parser()
        parser = app_class.specify_parser(parser)
        options = parser.parse_args()
        app = app_class(options)

        LOG.debug("Options: %s", options)

        try:
            return app.do()
        except KeyboardInterrupt:
            pass
        except Exception as exc:
            LOG.exception("Failed with error %s", exc)
            return os.EX_SOFTWARE

    return main_func 
开发者ID:9seconds,项目名称:concierge,代码行数:20,代码来源:common.py

示例9: catch_errors

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_SOFTWARE [as 别名]
def catch_errors(func):
    """Decorator which catches all errors and tries to print them."""

    @six.wraps(func)
    @click.pass_context
    def decorator(ctx, *args, **kwargs):
        try:
            return func(*args, **kwargs)
        except exceptions.DecapodAPIError as exc:
            utils.format_output_json(ctx, exc.json, True)
        except exceptions.DecapodError as exc:
            click.echo(six.text_type(exc), err=True)
        finally:
            ctx.close()

        ctx.exit(os.EX_SOFTWARE)

    return decorator 
开发者ID:Mirantis,项目名称:ceph-lcm,代码行数:20,代码来源:decorators.py

示例10: test_task_failed_exit

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_SOFTWARE [as 别名]
def test_task_failed_exit(mocked_plugin, tpool, configure_model, freeze_time):
    tsk = create_task()

    polled = {"a": False}

    def side_effect(*args, **kwargs):
        if polled["a"]:
            return False
        polled["a"] = True
        return True

    mocked_plugin.alive.side_effect = side_effect
    mocked_plugin.returncode = os.EX_SOFTWARE

    tpool.submit(tsk)
    time.sleep(2)
    tsk.refresh()
    assert tsk.executor_host == platform.node()
    assert tsk.executor_pid == 100
    assert tsk.time_failed == int(freeze_time.return_value)
    assert not tsk.time_cancelled
    assert not tsk.time_completed
    assert not tpool.global_stop_event.is_set()
    assert tsk._id not in tpool.data 
开发者ID:Mirantis,项目名称:ceph-lcm,代码行数:26,代码来源:test_taskpool.py

示例11: main

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_SOFTWARE [as 别名]
def main(args=None):
    parsed_args = parser.parse_args(args=args)
    logger.setLevel(parsed_args.log_level)
    has_attrs = (getattr(parsed_args, "sort_by", None) and getattr(parsed_args, "columns", None))
    if has_attrs and parsed_args.sort_by not in parsed_args.columns:
        parsed_args.columns.append(parsed_args.sort_by)
    try:
        result = parsed_args.entry_point(parsed_args)
    except Exception as e:
        if isinstance(e, NoRegionError):
            msg = "The AWS CLI is not configured."
            msg += " Please configure it using instructions at"
            msg += " http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html"
            exit(msg)
        elif logger.level < logging.ERROR:
            raise
        else:
            err_msg = traceback.format_exc()
            try:
                err_log_filename = os.path.join(config.user_config_dir, "error.log")
                with open(err_log_filename, "ab") as fh:
                    print(datetime.datetime.now().isoformat(), file=fh)
                    print(err_msg, file=fh)
                exit("{}: {}. See {} for error details.".format(e.__class__.__name__, e, err_log_filename))
            except Exception:
                print(err_msg, file=sys.stderr)
                exit(os.EX_SOFTWARE)
    if isinstance(result, SystemExit):
        raise result
    elif result is not None:
        if isinstance(result, dict) and "ResponseMetadata" in result:
            del result["ResponseMetadata"]
        print(json.dumps(result, indent=2, default=str)) 
开发者ID:kislyuk,项目名称:aegea,代码行数:35,代码来源:__init__.py

示例12: test_secrets

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_SOFTWARE [as 别名]
def test_secrets(self):
        unauthorized_ok = [dict(return_codes=[os.EX_OK]),
                           dict(return_codes=[1, os.EX_SOFTWARE], stderr="(AccessDenied|NoSuchKey)")]
        secret_name = "test_secret_{}".format(int(time.time()))
        self.call("{s}=test aegea secrets put {s} --iam-role aegea.launch".format(s=secret_name),
                  shell=True, expect=unauthorized_ok)
        self.call("aegea secrets put {s} --generate-ssh-key --iam-role aegea.launch".format(s=secret_name),
                  shell=True, expect=unauthorized_ok)
        self.call("aegea secrets ls", shell=True, expect=unauthorized_ok)
        self.call("aegea secrets ls --json", shell=True, expect=unauthorized_ok)
        self.call("aegea secrets get {s} --iam-role aegea.launch".format(s=secret_name), shell=True,
                  expect=unauthorized_ok)
        self.call("aegea secrets delete {s} --iam-role aegea.launch".format(s=secret_name), shell=True,
                  expect=unauthorized_ok) 
开发者ID:kislyuk,项目名称:aegea,代码行数:16,代码来源:test.py

示例13: _ManifestCheck

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_SOFTWARE [as 别名]
def _ManifestCheck(self):
    """Check the manifest.json file for required key/value pairs.

    Raises:
      ManifestError: when there is an issue with the manifest.json file.
    """
    logging.debug('Checking the manifest file...')
    with open(self.manifest_file, 'r') as manifest_data:
      try:
        data = json.load(manifest_data)
      # Catch syntax errors.
      except ValueError:
        sys.stderr.write(
            "The there is a syntax error in the Chrome App's"
            "manifest.json file, located at: {}\n".format(self.manifest_file))
        raise ManifestError(os.EX_SOFTWARE)
      # Set the new version.
      current_version = data['version']
      data['version'] = input(
          'The current Chrome App version is {}, '
          'please enter the new version: '.format(current_version))
      # Check for the Chrome App Key.
      if not data['key']:
        sys.stderr.write(
            "The manifest key is missing, please place it in the Chrome App's "
            "manifest.json file, located at: {}\n".format(self.manifest_file))
        raise ManifestError(os.EX_SOFTWARE)
      # Check for the OAuth2 Client ID.
      if not data['oauth2']['client_id']:
        sys.stderr.write(
            "The OAuth2 Client ID is missing for the Chrome App, please place "
            "it in the Chrome App's manifest.json, "
            "file located at: {}\n".format(
                self.manifest_file))
        raise ManifestError(os.EX_SOFTWARE)

    # Write new version to manifest.
    with open(self.manifest_file, 'w+') as manifest_data:
      json.dump(
          data, manifest_data, sort_keys=True, indent=2, separators=(',', ': ')) 
开发者ID:google,项目名称:loaner,代码行数:42,代码来源:deploy_impl.py

示例14: main

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_SOFTWARE [as 别名]
def main(argv=None):
    parser = argparse.ArgumentParser()
    parser.add_argument("segy_file", metavar="segy-file",
                        help="Path to an existing SEG Y file of 3D seismic data")

    parser.add_argument("npy_file", metavar="npy-file",
                        help="Path to the Numpy array file to be created for the timeslice")

    parser.add_argument("slice_index", metavar="slice-index", type=int,
                        help="Zero based index of the time slice to be extracted", )

    parser.add_argument("--dtype", type=nullable_dtype, default="",
                        help="Numpy data type. If not provided a dtype compatible with the SEG Y data will be used.")

    parser.add_argument("--null",  type=float, default=0.0,
                        help="Sample value to use for missing or short traces.")

    if argv is None:
        argv = sys.argv[1:]

    args = parser.parse_args(argv)

    try:
        extract_timeslice(args.segy_file,
                          args.npy_file,
                          args.slice_index,
                          args.dtype,
                          args.null)
    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,代码行数:40,代码来源:timeslice.py

示例15: main

# 需要导入模块: import os [as 别名]
# 或者: from os import EX_SOFTWARE [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


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