Exemple #1
0
def enable_adb(host='127.0.0.1', port=5037):
    adb = None
    try:
        adb = Adb(host, port)

        version = adb.client.version()

        if version != 41:
            raise RuntimeError(
                'Error: require adb version 41, but version is {}'.format(
                    version))

    except RuntimeError as err:

        adb_path = resource_path(FilePaths.ADB_EXE_PATH.value)

        ret = subprocess.run(build_command(adb_path, '-P', str(port),
                                           'kill-server', host),
                             shell=True,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE,
                             encoding="utf-8")

        ret = subprocess.run(build_command(adb_path, '-P', str(port),
                                           'connect', host),
                             shell=True,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE,
                             encoding="utf-8")

        if ret.returncode != 0:
            raise RuntimeError(
                'Error: fail to start adb server. \n({})'.format(ret))

    return adb
Exemple #2
0
 def connect_to_device(self, host='127.0.0.1', port=5555):
     adb_path = resource_path(FilePaths.ADB_EXE_PATH.value)
     cmd = build_command(adb_path, 'connect', "{}:{}".format(host, port))
     ret = subprocess.check_output(cmd,
                                   shell=True,
                                   stderr=subprocess.PIPE,
                                   encoding="utf-8",
                                   timeout=2)
     return self.get_device(host, port)
Exemple #3
0
def teardown():
    global ctr, dkr
    default_teardown()
    if dkr is not None:
        dkr.stop(ctr)


test_steps = [
    create_script,
    ("Create repository", "git init"),
    ("Add main file", "git add main.py"),
    ("Commit main file", "git commit -m 'initial'"),
    start_pg_container,
    ("Set up a Sumatra project",
     build_command(
         "smt init --store=postgres://docker:docker@{}/sumatra_test -m main.py -e python MyProject",
         "url")),
    #"smt init -m main.py -e python MyProject"),
    ("Show project configuration", "smt info"),  # TODO: add assert
    ("Run a computation", "smt run")
]

# TODO: add test skips where docker, psycopg2 not found


def test_all():
    """Test generator for Nose."""
    if not have_psycopg2:
        raise SkipTest("Tests require psycopg2")
    if not have_docker:
        raise SkipTest("Tests require docker")
Exemple #4
0
def teardown():
    global ctr, dkr
    default_teardown()
    if dkr is not None:
        dkr.stop(ctr)


##utils.env["url"] = "127.0.0.1:8642"

test_steps = [
    start_server,
    ("Get the example code", "hg clone %s ." % repository, assert_in_output,
     "updating to branch default"),
    ("Set up a Sumatra project",
     build_command(
         "smt init --store=http://testuser:abc123@{}/records/ -m glass_sem_analysis.py -e python -d Data -i . ProjectGlass",
         "url")),
    ("Run the ``glass_sem_analysis.py`` script with Sumatra",
     "smt run -r 'initial run' default_parameters MV_HFV_012.jpg",
     assert_in_output, ("2416.86315789 60.0", "histogram.png")),
    ("Comment on the outcome", "smt comment 'works fine'"),
    edit_parameters("default_parameters", "no_filter", "filter_size", 1),
    (
        "Run with changed parameters and user-defined label",
        "smt run -l example_label -r 'No filtering' no_filter MV_HFV_012.jpg",  # TODO: assert(results have changed)
        assert_in_output,
        "phases.png",
        assert_label_equal,
        "example_label"),
    ("Change parameters from the command line",
     "smt run -r 'Trying a different colourmap' default_parameters MV_HFV_012.jpg phases_colourmap=hot"
Exemple #5
0
  "smt configure -e python -m glass_sem_analysis.py"),
 ("Look at the current configuration of the project",
  "smt info",
  assert_config, {"project_name": "ProjectGlass", "executable": "Python", "main": "glass_sem_analysis.py",
                  "code_change": "error"}),
 edit_parameters("default_parameters", "no_filter", "filter_size", 1),
 ("Run with changed parameters and user-defined label",
  "smt run -l example_label -r 'No filtering' no_filter MV_HFV_012.jpg",  # TODO: assert(results have changed)
  assert_in_output, "phases.png",
  assert_label_equal, "example_label"),
 ("Change parameters from the command line",
  "smt run -r 'Trying a different colourmap' default_parameters MV_HFV_012.jpg phases_colourmap=hot"),  # assert(results have changed)
 ("Add another comment",
  "smt comment 'The default colourmap is nicer'"),  #TODO  add a comment to an older record (e.g. this colourmap is nicer than 'hot')")
 ("Add tags on the command line",
  build_command("smt tag mytag {0} {1}", "labels")),
 modify_script("glass_sem_analysis.py"),
 ("Run the modified code",
  "smt run -r 'Added labels to output' default_parameters MV_HFV_012.jpg",
  assert_return_code, 1,
  assert_in_output, "Code has changed, please commit your changes"),
 ("Commit changes...",
  "hg commit -m 'Added labels to output' -u testuser"),
 ("...then run again",
  "smt run -r 'Added labels to output' default_parameters MV_HFV_012.jpg"),  # assert(output has changed as expected)
 #TODO: make another change to the Python script
 ("Change configuration to store diff",
  "smt configure --on-changed=store-diff"),
 ("Run with store diff",
  "smt run -r 'made a change' default_parameters MV_HFV_012.jpg"),  # assert(code runs, stores diff)
 ("Review previous computations - get a list of labels",
Exemple #6
0
def teardown():
    global ctr, dkr
    default_teardown()
    if dkr is not None:
        dkr.stop(ctr)


test_steps = [
    create_script,
    ("Create repository", "git init"),
    ("Add main file", "git add main.py"),
    ("Commit main file", "git commit -m 'initial'"),
    start_pg_container,
    ("Set up a Sumatra project",
     build_command("smt init --store=postgres://docker:docker@{}/sumatra_test -m main.py -e python MyProject", "url")),
     #"smt init -m main.py -e python MyProject"),
    ("Show project configuration", "smt info"),  # TODO: add assert
    ("Run a computation", "smt run")
]


# TODO: add test skips where docker, psycopg2 not found


def test_all():
    """Test generator for Nose."""
    if not have_psycopg2:
        raise SkipTest("Tests require psycopg2")
    if not have_docker:
        raise SkipTest("Tests require docker")
Exemple #7
0
def teardown():
    global ctr, dkr
    default_teardown()
    if dkr is not None:
        dkr.stop(ctr)

##utils.env["url"] = "127.0.0.1:8642"


test_steps = [
    start_server,
    ("Get the example code",
     "hg clone %s ." % repository,
     assert_in_output, "updating to branch default"),
    ("Set up a Sumatra project",
     build_command("smt init --store=http://testuser:abc123@{}/records/ -m glass_sem_analysis.py -e python -d Data -i . ProjectGlass", "url")),
    ("Run the ``glass_sem_analysis.py`` script with Sumatra",
     "smt run -r 'initial run' default_parameters MV_HFV_012.jpg",
     assert_in_output, ("2416.86315789 60.0", "histogram.png")),
    ("Comment on the outcome",
     "smt comment 'works fine'"),
    edit_parameters("default_parameters", "no_filter", "filter_size", 1),
    ("Run with changed parameters and user-defined label",
     "smt run -l example_label -r 'No filtering' no_filter MV_HFV_012.jpg",  # TODO: assert(results have changed)
     assert_in_output, "phases.png",
     assert_label_equal, "example_label"),
    ("Change parameters from the command line",
     "smt run -r 'Trying a different colourmap' default_parameters MV_HFV_012.jpg phases_colourmap=hot"),  # assert(results have changed)
    ("Add another comment",
     "smt comment 'The default colourmap is nicer'"),  #TODO  add a comment to an older record (e.g. this colourmap is nicer than 'hot')")
    ("Add tags on the command line",
def teardown():
    global ctr, dkr
    default_teardown()
    if dkr is not None:
        dkr.stop(ctr)


test_steps = [
    create_script,
    ("Create repository", "git init"),
    ("Add main file", "git add main.py"),
    ("Commit main file", "git commit -m 'initial'"),
    start_webdav_container,
    ("Set up a Sumatra project",
     build_command("smt init -W=http://sumatra:sumatra@{}/webdav/ -m main.py -e python MyProject", "url")),
     #"smt init -m main.py -e python MyProject"),
    ("Show project configuration", "smt info"),  # TODO: add assert
    ("Run a computation", "smt run")
]


def test_all():
    """Test generator for Nose."""
    if not have_docker:
        raise SkipTest("Tests require docker")
    for step in test_steps:
        if callable(step):
            step()
        else:
            run_test.description = step[0]
Exemple #9
0
def teardown():
    global ctr, dkr
    default_teardown()
    if dkr is not None:
        dkr.stop(ctr)


test_steps = [
    create_script,
    ("Create repository", "git init"),
    ("Add main file", "git add main.py"),
    ("Commit main file", "git commit -m 'initial'"),
    start_webdav_container,
    ("Set up a Sumatra project",
     build_command(
         "smt init -W=http://sumatra:sumatra@{}/webdav/ -m main.py -e python MyProject",
         "url")),
    #"smt init -m main.py -e python MyProject"),
    ("Show project configuration", "smt info"),  # TODO: add assert
    ("Run a computation", "smt run")
]


def test_all():
    """Test generator for Nose."""
    if not have_docker:
        raise SkipTest("Tests require docker")
    for step in test_steps:
        if callable(step):
            step()
        else:
Exemple #10
0
  "smt configure -e python -m glass_sem_analysis.py"),
 ("Look at the current configuration of the project",
  "smt info",
  assert_config, {"project_name": "ProjectGlass", "executable": "Python", "main": "glass_sem_analysis.py",
                  "code_change": "error"}),
 edit_parameters("default_parameters", "no_filter", "filter_size", 1),
 ("Run with changed parameters and user-defined label",
  "smt run -l example_label -r 'No filtering' no_filter MV_HFV_012.jpg",  # TODO: assert(results have changed)
  assert_in_output, "phases.png",
  assert_label_equal, "example_label"),
 ("Change parameters from the command line",
  "smt run -r 'Trying a different colourmap' default_parameters MV_HFV_012.jpg phases_colourmap=hot"),  # assert(results have changed)
 ("Add another comment",
  "smt comment 'The default colourmap is nicer'"),  #TODO  add a comment to an older record (e.g. this colourmap is nicer than 'hot')")
 ("Add tags on the command line",
  build_command("smt tag mytag {0} {1}", "labels")),
 modify_script("glass_sem_analysis.py"),
 ("Run the modified code",
  "smt run -r 'Added labels to output' default_parameters MV_HFV_012.jpg",
  assert_in_output, "Code has changed, please commit your changes"),
 ("Commit changes...",
  "hg commit -m 'Added labels to output' -u testuser"),
 ("...then run again",
  "smt run -r 'Added labels to output' default_parameters MV_HFV_012.jpg"),  # assert(output has changed as expected)
 #TODO: make another change to the Python script
 ("Change configuration to store diff",
  "smt configure --on-changed=store-diff"),
 ("Run with store diff",
  "smt run -r 'made a change' default_parameters MV_HFV_012.jpg"),  # assert(code runs, stores diff)
 ("Review previous computations - get a list of labels",
  "smt list",