Beispiel #1
0
def init(suites_yaml=None,
         claw_home=None,
         reset=False):
    """Initialize a claw environment."""
    if settings.settings_path.exists() and not reset:
        raise INIT_EXISTS
    if not suites_yaml:
        system_tests_dir = os.path.dirname(os.path.dirname(
            cosmo_tester.__file__))
        suites_yaml = os.path.join(system_tests_dir, 'suites', 'suites',
                                   'suites.yaml')
    suites_yaml = os.path.expanduser(suites_yaml)
    if not os.path.exists(suites_yaml):
        raise argh.CommandError(
            'suites.yaml not found at {0}'.format(suites_yaml))
    if not claw_home:
        claw_home = os.getcwd()
    settings.write_settings(claw_home, suites_yaml)
    settings.user_suites_yaml.write_text(resources.get(
        'templates/suites.template.yaml'))
    settings.blueprints_yaml.write_text(resources.get(
        'templates/blueprints.template.yaml'))
    (settings.claw_home / '.gitignore').write_text(resources.get(
        'templates/gitignore.template'))
    settings.configurations.mkdir_p()
    settings.default_scripts_dir.mkdir_p()
    generate_script(settings.default_scripts_dir / 'example-script.py',
                    reset=True)
Beispiel #2
0
def init(suites_yaml=None, claw_home=None, reset=False):
    """Initialize a claw environment."""
    if settings.settings_path.exists() and not reset:
        raise INIT_EXISTS
    if not suites_yaml:
        system_tests_dir = os.path.dirname(
            os.path.dirname(cosmo_tester.__file__))
        suites_yaml = os.path.join(system_tests_dir, 'suites', 'suites',
                                   'suites.yaml')
    suites_yaml = os.path.expanduser(suites_yaml)
    if not os.path.exists(suites_yaml):
        raise argh.CommandError(
            'suites.yaml not found at {0}'.format(suites_yaml))
    if not claw_home:
        claw_home = os.getcwd()
    settings.write_settings(claw_home, suites_yaml)
    settings.user_suites_yaml.write_text(
        resources.get('templates/suites.template.yaml'))
    settings.blueprints_yaml.write_text(
        resources.get('templates/blueprints.template.yaml'))
    (settings.claw_home / '.gitignore').write_text(
        resources.get('templates/gitignore.template'))
    settings.configurations.mkdir_p()
    settings.default_scripts_dir.mkdir_p()
    generate_script(settings.default_scripts_dir / 'example-script.py',
                    reset=True)
Beispiel #3
0
 def _verify_init(self, expected_claw_home, expected_suites_yaml):
     self.assertTrue(self.settings.settings_path.exists())
     self.assertEqual(self.settings.claw_home, expected_claw_home)
     self.assertEqual(self.settings.main_suites_yaml, expected_suites_yaml)
     self.assertEqual(self.settings.user_suites_yaml.text(), resources.get("templates/suites.template.yaml"))
     self.assertEqual(self.settings.blueprints_yaml.text(), resources.get("templates/blueprints.template.yaml"))
     self.assertEqual((self.settings.claw_home / ".gitignore").text(), resources.get("templates/gitignore.template"))
     self.assertEqual(
         (self.settings.default_scripts_dir / "example-script.py").text(),
         resources.get("templates/script.template.py"),
     )
     self.assertTrue(self.settings.configurations.exists())
Beispiel #4
0
 def _verify_init(self, expected_claw_home, expected_suites_yaml):
     self.assertTrue(self.settings.settings_path.exists())
     self.assertEqual(self.settings.claw_home, expected_claw_home)
     self.assertEqual(self.settings.main_suites_yaml, expected_suites_yaml)
     self.assertEqual(self.settings.user_suites_yaml.text(),
                      resources.get('templates/suites.template.yaml'))
     self.assertEqual(self.settings.blueprints_yaml.text(),
                      resources.get('templates/blueprints.template.yaml'))
     self.assertEqual((self.settings.claw_home / '.gitignore').text(),
                      resources.get('templates/gitignore.template'))
     self.assertEqual(
         (self.settings.default_scripts_dir / 'example-script.py').text(),
         resources.get('templates/script.template.py'))
     self.assertTrue(self.settings.configurations.exists())
Beispiel #5
0
def cdconfiguration():
    if not settings.settings_path.exists():
        return
    cdconfiguration_template = resources.get(
        'templates/cdconfiguration.template.sh')
    sys.stdout.write(cdconfiguration_template.replace('{{configurations}}',
                                                      settings.configurations))
Beispiel #6
0
def generate_script(script_path, reset=False):
    """Generate a scaffold script."""
    if os.path.exists(script_path) and not reset:
        raise argh.CommandError('{0} already exists'.format(script_path))
    with open(script_path, 'w') as f:
        f.write(resources.get('templates/script.template.py'))
    os.chmod(script_path, os.stat(script_path).st_mode | 0o111)
Beispiel #7
0
def generate_script(script_path, reset=False):
    """Generate a scaffold script."""
    if os.path.exists(script_path) and not reset:
        raise argh.CommandError('{0} already exists'.format(script_path))
    with open(script_path, 'w') as f:
        f.write(resources.get('templates/script.template.py'))
    os.chmod(script_path, os.stat(script_path).st_mode | 0o111)
Beispiel #8
0
def cdconfiguration():
    if not settings.settings_path.exists():
        return
    cdconfiguration_template = resources.get(
        'templates/cdconfiguration.template.sh')
    sys.stdout.write(
        cdconfiguration_template.replace('{{configurations}}',
                                         settings.configurations))
Beispiel #9
0
def cdconfiguration():
    """Output bash function and completion for cdconfiguration."""
    if not settings.settings_path.exists():
        return
    cdconfiguration_template = resources.get(
        'templates/cdconfiguration.template.sh')
    sys.stdout.write(cdconfiguration_template.replace('{{configurations}}',
                                                      settings.configurations))
Beispiel #10
0
def cdconfiguration():
    """Output bash function and completion for cdconfiguration."""
    if not settings.settings_path.exists():
        return
    cdconfiguration_template = resources.get(
        'templates/cdconfiguration.template.sh')
    sys.stdout.write(cdconfiguration_template.replace('{{configurations}}',
                                                      settings.configurations))