コード例 #1
0
ファイル: info.py プロジェクト: pauloalmendra/CTF
 def returns_other_by_default(self, cxn):
     # Sentinels don't exist -> yields default
     # TODO: refactor with module contents in feature branch, eg tease
     # out sentinel file definitions to module level data
     # TODO: make a Session-like thing (or just allow reuse of Session?)
     # that works at this level instead of what it currently does in
     # MockRemote, mocking lower level stuff that is doubtlessly slower
     # and not really necessary?
     cxn.run.return_value = Result(connection=cxn, exited=1)
     assert distro_name(cxn) == "other"
コード例 #2
0
ファイル: info.py プロジェクト: fabric/patchwork
 def returns_other_by_default(self, cxn):
     # Sentinels don't exist -> yields default
     # TODO: refactor with module contents in feature branch, eg tease
     # out sentinel file definitions to module level data
     # TODO: make a Session-like thing (or just allow reuse of Session?)
     # that works at this level instead of what it currently does in
     # MockRemote, mocking lower level stuff that is doubtlessly slower
     # and not really necessary?
     cxn.run.return_value = Result(connection=cxn, exited=1)
     assert distro_name(cxn) == "other"
コード例 #3
0
ファイル: info.py プロジェクト: pauloalmendra/CTF
        def returns_centos_if_centos_release_exists(self, cxn):
            def centos_exists(*args, **kwargs):
                # TODO: this is crazy fragile, indicates we want to refactor
                # the guts of exists() or just mock exists() itself instead
                if args[0] == 'test -e "$(echo /etc/centos-release)"':
                    return Result(connection=cxn, exited=0)
                return Result(connection=cxn, exited=1)

            cxn.run.side_effect = centos_exists
            assert distro_name(cxn) == "centos"
コード例 #4
0
ファイル: info.py プロジェクト: fabric/patchwork
        def returns_centos_if_centos_release_exists(self, cxn):

            def centos_exists(*args, **kwargs):
                # TODO: this is crazy fragile, indicates we want to refactor
                # the guts of exists() or just mock exists() itself instead
                if args[0] == 'test -e "$(echo /etc/centos-release)"':
                    return Result(connection=cxn, exited=0)
                return Result(connection=cxn, exited=1)

            cxn.run.side_effect = centos_exists
            assert distro_name(cxn) == "centos"
コード例 #5
0
ファイル: fabfile.py プロジェクト: pydemic/pydemic-ui
def configure(ctx):
    """
    Configure host with Docker, docker-compose, etc.
    """
    print("Warning! This command is still under development!")

    # Check distro
    distro = info.distro_family(ctx)
    if distro != "debian":
        print(f"Only supports Debian-based distros, got '{distro}'",
              file=sys.stderr)
        return

    distro = info.distro_name(ctx)
    print(f"Installing packages on {distro} machine...")
    print("This recipe was tested on Ubuntu.")

    # Install required packages
    packages.package(ctx, "python3-pip")
    ctx.run("pip3 install docker-compose")
    git_clone(ctx)
コード例 #6
0
ファイル: test_distro.py プロジェクト: mstewart/patchwork
 def test_amazon_detection_via_lsb_release(self, run, lsb_release):
     lsb_release.return_value = amazon2012_03_lsb_info
     self.assertEqual(info.distro_name(), 'amazon')
     lsb_release.assert_called()
     self.assertFalse(run.called)
コード例 #7
0
ファイル: test_distro.py プロジェクト: mstewart/patchwork
 def test_ubuntu_detection_via_lsb_release(self, run, lsb_release):
     lsb_release.return_value = ubuntu1104_lsb_info
     self.assertEqual(info.distro_name(), 'ubuntu')
     lsb_release.assert_called()
     self.assertFalse(run.called)
コード例 #8
0
ファイル: fabfile.py プロジェクト: xarg/patchwork
def get_distro_name():
    """ Demo: Get your distro name """

    name = info.distro_name()
    print(name)