Ejemplo n.º 1
0
    def install(self, backend):
        """Install the GUI and dependencies."""
        # If the source setting has changed since the last time this was run,
        # get the code, from either a static release or a branch as specified
        # by the souce setting, and install it.
        if backend.different("juju-gui-source"):
            # Get a tarball somehow.
            origin, version_or_branch = utils.parse_source(backend.config["juju-gui-source"])
            if origin == "develop":
                # Develop is the latest passing build from Git.
                origin = "branch"
                version_or_branch = ("https://github.com/juju/juju-gui.git", "develop")

            if origin == "branch":
                logpath = backend.config["command-log-file"]
                # Make sure we have the required build dependencies.
                # Note that we also need to add the juju-gui repository
                # containing our version of nodejs.
                log("Installing build dependencies.")
                utils.install_missing_packages(
                    utils.DEB_BUILD_DEPENDENCIES, repository=backend.config["repository-location"]
                )

                branch_url, revision = version_or_branch
                log("Using source {}: {}".format(branch_url, revision))

                release_tarball_path = utils.fetch_gui_from_branch(branch_url, revision, logpath)
            else:
                release_tarball_path = utils.fetch_gui_release(origin, version_or_branch)
            # Install the tarball.
            utils.setup_gui(release_tarball_path)
        else:
            log("No change to juju-gui-source. Skipping step.")
def generate_data(project):
    sub_dir = os.path.join(dir_name, project)
    err_num, success_num = 0, 0
    for file_name in os.listdir(sub_dir):
        try:
            with open(os.path.join(sub_dir, file_name), 'r') as f:
                source_code = f.readlines()
            new_source_code = parse_source(source_code)
            with open(os.path.join(out_dir, project + '_' + file_name),
                      'w') as f:
                f.writelines(new_source_code)
                success_num += 1
        except:
            err_num += 1
            print('error', project, file_name)
            pass
    print(err_num, success_num)
Ejemplo n.º 3
0
    def install(self, backend):
        """Install the GUI and dependencies."""
        # If the source setting has changed since the last time this was run,
        # get the code, from either a static release or a branch as specified
        # by the souce setting, and install it.
        if backend.different('juju-gui-source'):
            # Get a tarball somehow.
            origin, version_or_branch = utils.parse_source(
                backend.config['juju-gui-source'])
            if origin == 'develop':
                # Develop is the latest passing build from Git.
                origin = 'branch'
                version_or_branch = ('https://github.com/juju/juju-gui.git',
                                     'develop')

            if origin == 'branch':
                logpath = backend.config['command-log-file']
                # Make sure we have the required build dependencies.
                # Note that we also need to add the juju-gui repository
                # containing our version of nodejs.
                log('Installing build dependencies.')
                utils.install_missing_packages(
                    utils.DEB_BUILD_DEPENDENCIES,
                    repository=backend.config['repository-location'])

                branch_url, revision = version_or_branch
                log('Using source {}: {}'.format(branch_url, revision))

                release_tarball_path = utils.fetch_gui_from_branch(
                    branch_url, revision, logpath)
            else:
                release_tarball_path = utils.fetch_gui_release(
                    origin, version_or_branch)
            # Install the tarball.
            utils.setup_gui(release_tarball_path)
        else:
            log('No change to juju-gui-source. Skipping step.')
Ejemplo n.º 4
0
 def test_relative_file_url(self):
     expected = ('url', 'file:///current/dir/foo/bar')
     self.assertTupleEqual(expected, parse_source('url:foo/bar'))
Ejemplo n.º 5
0
 def test_file_url(self):
     expected = ('url', 'file:///foo/bar')
     self.assertTupleEqual(expected, parse_source('url:/foo/bar'))
Ejemplo n.º 6
0
 def test_url(self):
     expected = ('url', 'http://example.com/gui')
     self.assertTupleEqual(
         expected, parse_source('url:http://example.com/gui'))
Ejemplo n.º 7
0
 def test_bzr_branch_and_revision(self):
     # A Bazaar branch is correctly parsed when including revision.
     sources = ('lp:example:42', 'http://bazaar.launchpad.net/example:1')
     for source in sources:
         expected = ('branch', tuple(source.rsplit(':', 1)))
         self.assertEqual(expected, parse_source(source))
Ejemplo n.º 8
0
 def test_bzr_branch(self):
     # Ensure a Bazaar branch is correctly parsed.
     sources = ('lp:example', 'http://bazaar.launchpad.net/example')
     for source in sources:
         expected = ('branch', (source, None))
         self.assertEqual(expected, parse_source(source))
Ejemplo n.º 9
0
 def test_trunk_release(self):
     # Ensure a specific trunk release is correctly parsed.
     expected = ('trunk', '0.1.0+build.1')
     self.assertTupleEqual(expected, parse_source('0.1.0+build.1'))
Ejemplo n.º 10
0
 def test_stable_release(self):
     # Ensure a specific stable release is correctly parsed.
     expected = ('stable', '0.1.0')
     self.assertTupleEqual(expected, parse_source('0.1.0'))
Ejemplo n.º 11
0
 def test_latest_trunk_release(self):
     # Ensure the latest trunk release is correctly parsed.
     expected = ('trunk', None)
     self.assertTupleEqual(expected, parse_source('trunk'))
Ejemplo n.º 12
0
 def test_latest_stable_release(self):
     # Ensure the latest stable release is correctly parsed.
     expected = ('stable', None)
     self.assertTupleEqual(expected, parse_source('stable'))
Ejemplo n.º 13
0
 def test_latest_local_release(self):
     # Ensure the latest local release is correctly parsed.
     expected = ('local', None)
     self.assertTupleEqual(expected, parse_source('local'))