Пример #1
0
def test_metadata():
    expected = pytest.__version__

    v = get_version.get_version_from_metadata("pytest")
    assert get_version.Version(expected, None, []) == v

    v = get_version.get_version("pytest")
    assert expected == v

    v = get_version.get_version(Path(pytest.__file__))
    assert expected == v
Пример #2
0
def test_dir_dash(temp_tree: TempTreeCB):
    dirname = "dir-two-0.1"
    spec = {dirname: {"dir_two.py": "print('hi!')\n"}}
    with temp_tree(spec) as package:
        v = get_version.get_version_from_dirname("dir-two", package / dirname)
        assert get_version.Version("0.1", None, []) == v

        v = get_version.get_version(package / dirname / "dir_two.py")
        assert "0.1" == v
Пример #3
0
def test_dir(temp_tree: TempTreeCB):
    dirname = "dir_mod-0.1.3+dirty"
    spec = {dirname: {"dir_mod.py": "print('hi!')\n"}}
    with temp_tree(spec) as package:
        v = get_version.get_version_from_dirname("dir_mod", package / dirname)
        assert get_version.Version("0.1.3", None, ["dirty"]) == v

        v = get_version.get_version(package / dirname / "dir_mod.py")
        assert "0.1.3+dirty" == v
Пример #4
0
def test_git(temp_tree: TempTreeCB):
    spec = {".git": {}, "git_mod.py": "print('hello')\n"}
    with temp_tree(spec) as package, MockCommand(
            "git", mock_git_describe.format(package)):
        v = get_version.get_version_from_git(package)
        assert get_version.Version("0.1.2", "3", ["fefe123", "dirty"]) == v

        v = get_version.get_version(package / "git_mod.py")
        assert "0.1.2.dev3+fefe123.dirty" == v
Пример #5
0
def run():

    global current_process
    global current_process_id

    register_signals()

    version = get_version()

    print "Server version is", version
    print "Starting eternal server"
    MAX_DUMPS = 100
    ct = 0

    subprocess.Popen('ulimit -c unlimited', shell=True)

    while True:

        print '%d-th server run' % ct

        logname = 'log-%s-%d' % (
            version,
            time.time(),
        )
        corename = 'core-%s-%d' % (version, time.time())
        mapname = './world/map-%d.map' % (version, )
        if not os.path.exists(mapname):
            mapname = './world/map-%d.map.bak' % (version, )
            if not os.path.exists(mapname):
                mapname = ''

        cmd = './shell/m643_run_log.sh %s %s' % (
            logname,
            mapname,
        )

        current_process = subprocess.Popen(shlex.split(cmd))
        current_process_id = current_process.pid
        current_process.wait()

        print "Server died"

        ct += 1
        if ct >= MAX_DUMPS:
            print "Reached max core dumps."
            break
        if os.path.exists("./core"):
            print "Core dumped; saving"
            os.rename("./core",
                      "/home/gnomescroll/gsdata/coredumps/%s" % (corename, ))
        if os.path.exists("./%s" % (logname, )):
            print "Saving %s" % (logname, )
            os.rename("./%s" % (logname, ),
                      "/home/gnomescroll/gsdata/coredumps/%s" % (logname, ))

    subprocess.Popen('ulimit -c 0', shell=True)
Пример #6
0
def _check_schema_version(args, metadata, config):
    try:
        (current_version,
         installing_version) = get_version.get_version(metadata,
                                                       config,
                                                       args.schema_dir)

        if current_version or installing_version:
            raise Error("Database already installed.")
    except get_version.Error:
        pass
Пример #7
0
def _run(args, metadata, config):
    target_version = metadata["version"]
    can_upgrade_from = metadata["upgrade-from"]

    print "Target schema version: {0}".format(target_version)

    try:
        (current_version,
         installing_version) = get_version.get_version(metadata, config,
                                                       args.schema_dir)
    except get_version.Error as error:
        raise Error("Database schema version unknown.\n\n{0}".format(error))

    if installing_version is None:
        if current_version is None:
            raise Error("Database schema version unknown.")

        print("Database schema version: {0}".format(current_version))

        if current_version == target_version:
            print "\nDatabase schema is up-to-date."
        elif current_version in can_upgrade_from:
            print(
                "\nTo upgrade database to schema version {0}, use the "
                "'upgrade' command.".format(target_version))
        else:
            print(
                "\nDirect upgrade from schema version {0} to {1} is not "
                "supported.".format(current_version, target_version))

            if can_upgrade_from:
                print("Supported schema versions for upgrade: "
                      "{0}".format(", ".join(can_upgrade_from)))
    else:
        if current_version is None:
            print(
                "Database schema version: incomplete installation of "
                "version {0}".format(installing_version))
            if installing_version == target_version:
                print(
                    "\nConsider destroying the database (this will destroy "
                    "all data) and using the 'install' command to "
                    "reattempt installation of schema version "
                    "{0}.".format(target_version))
        else:
            print(
                "Database schema version: incomplete upgrade from version "
                "{0} to {1}".format(current_version, installing_version))
            if installing_version == target_version:
                print(
                    "\nTo reattempt upgrade to schema version {0}, use the "
                    "'upgrade' command with the '--retry' "
                    "option.".format(target_version))
Пример #8
0
def test_dir(temp_tree: TempTreeCB, has_src, version, distname):
    content: Desc = {"dir_mod.py": "print('hi!')\n"}
    if has_src:
        content = dict(src=content)
    dirname = f"{distname}-{version}"
    spec: Desc = {dirname: content}
    with temp_tree(spec) as package:
        v = get_version.get_version_from_dirname(package / dirname)
        assert version == v

        parent = (package / dirname / "src") if has_src else (package /
                                                              dirname)
        v = get_version.get_version(parent / "dir_mod.py")
        assert version == v
Пример #9
0
def test_git(temp_tree: TempTreeCB, has_src, with_v, version):
    src_path = Path("git_mod.py")
    content: Desc = {src_path: "print('hello')\n"}
    if has_src:
        src_path = Path("src") / src_path
        content = dict(src=content)
    with temp_tree(content) as package:
        with get_version.working_dir(package):

            def add_and_commit(msg: str):
                run(f"git add {src_path}".split(), check=True)
                run([*"git commit -m".split(), msg], check=True)

            run("git init".split(), check=True)
            add_and_commit("initial")
            run(f"git tag {'v' if with_v else ''}{version}".split(),
                check=True)
            src_path.write_text("print('modified')")
            add_and_commit("modified")
            hash = run(
                "git rev-parse --short HEAD".split(),
                capture_output=True,
                encoding="ascii",
            ).stdout.strip()
            src_path.write_text("print('dirty')")

        v = get_version.dunamai_get_from_vcs(package)
        assert (Version(
            version.base,
            stage=(version.stage, version.revision),
            distance=1,
            commit=hash,
            dirty=True,
        ) == v)

        parent = (package / "src") if has_src else package
        v_str = get_version.get_version(parent / "git_mod.py")
        assert f"{version}.post1.dev0+{hash}.dirty" == v_str
Пример #10
0
def _check_schema_version(args, metadata, config):
    target_version = metadata["version"]
    can_upgrade_from = metadata["upgrade-from"]

    try:
        (current_version,
         installing_version) = get_version.get_version(metadata,
                                                       config,
                                                       args.schema_dir)
    except get_version.Error:
        raise Error("Database not installed.")

    if current_version is None:
        if installing_version is None:
            raise Error("Database schema version unknown.")
        else:
            raise Error("Incomplete database installation exists. Run "
                        "'version' command for more information.")

    if installing_version is not None:
        if installing_version != target_version:
            raise Error("Previous upgrade is incomplete. Run 'version' "
                        "command for more information.")

        if not args.retry:
            raise Error("Previous upgrade is incomplete. Use '--retry' "
                        "option to reattempt upgrade. Run 'version' command "
                        "for more information.")

    if current_version == target_version:
        if not args.force:
            raise Error("Database is already up-to-date. Run 'version' "
                        "command for more information.")
    elif current_version not in can_upgrade_from:
        raise Error("Direct upgrade from schema version {0} to {1} is not "
                    "supported. Run 'version' command for more "
                    "information.".format(current_version, target_version))
Пример #11
0
def _check_schema_version(args, metadata, config):
    target_version = metadata["version"]
    can_upgrade_from = metadata["upgrade-from"]

    try:
        (current_version,
         installing_version) = get_version.get_version(metadata, config,
                                                       args.schema_dir)
    except get_version.Error:
        raise Error("Database not installed.")

    if current_version is None:
        if installing_version is None:
            raise Error("Database schema version unknown.")
        else:
            raise Error("Incomplete database installation exists. Run "
                        "'version' command for more information.")

    if installing_version is not None:
        if installing_version != target_version:
            raise Error("Previous upgrade is incomplete. Run 'version' "
                        "command for more information.")

        if not args.retry:
            raise Error("Previous upgrade is incomplete. Use '--retry' "
                        "option to reattempt upgrade. Run 'version' command "
                        "for more information.")

    if current_version == target_version:
        if not args.force:
            raise Error("Database is already up-to-date. Run 'version' "
                        "command for more information.")
    elif current_version not in can_upgrade_from:
        raise Error("Direct upgrade from schema version {0} to {1} is not "
                    "supported. Run 'version' command for more "
                    "information.".format(current_version, target_version))
Пример #12
0
def test_version():
    assert get_version('pytest') == __version__
Пример #13
0
 def test_version(self):
     expected_version = get_version.get_version()
     self.assertEqual(fwd9m.__version__, expected_version)
Пример #14
0
    def do_get_version(self, input):
        '''get_version

        Prints the version of witness running on the server
        '''
        get_version.get_version(self._service)
Пример #15
0
 def test_version(self):
     expected_version = get_version()
     self.assertEqual(tfd_version, expected_version)
     self.assertEqual(tfd.__version__, expected_version)
Пример #16
0
from benchmark import Benchmark
from lease_manager import LeaseManager
from daemonize import Daemon

# import utility methods
from logging import DEBUG, INFO, WARNING, WARN, ERROR, CRITICAL
from logger import get_logger, logger, LogReporter
from ids import *
from read_json import *
from tracer import trace, untrace
from which import which
from misc import *
from get_version import get_version
from algorithms import *

# import decorators
from timing import timed_method

# import sub-modules
# from config         import Configuration, Configurable, ConfigOption, getConfig

# ------------------------------------------------------------------------------

import os

_mod_root = os.path.dirname(__file__)

version, version_detail, version_branch, sdist_name, sdist_path = get_version()

# ------------------------------------------------------------------------------
 def test_version(self):
     self.assertEqual(tfd.__version__, get_version())
Пример #18
0
"""trVAE - Regularized Conditional Variational Autoencoders"""

from . import models as archs
from . import utils as tl
from . import data_loader as dl
from . import plotting as pl
from . import metrics as mt

__author__ = ', '.join(['Mohsen Naghipourfar', 'Mohammad Lotfollahi'])

__email__ = ', '.join([
    '*****@*****.**',
    '*****@*****.**',
])

from get_version import get_version
__version__ = get_version(__file__)

del get_version
Пример #19
0
from lease_manager  import LeaseManager
from daemonize      import Daemon

# import utility methods
from ids            import *
from read_json      import *
from tracer         import trace, untrace
from which          import which
from misc           import *
from get_version    import get_version
from algorithms     import *

# import decorators
from timing         import timed_method

# import sub-modules
# from config         import Configuration, Configurable, ConfigOption, getConfig


# ------------------------------------------------------------------------------


import os

_mod_root = os.path.dirname (__file__)

version, version_detail, version_branch, sdist_name, sdist_path = get_version()

# ------------------------------------------------------------------------------