コード例 #1
0
ファイル: git.py プロジェクト: lupine37/gps
 def _worktrees(self, visitor):
     """
     A generator that returns the list of worktrees via `visitor.branches`
     """
     # "--no-pager" results in segfault with git 2.11
     p = ProcessWrapper(['git', 'worktree', 'list', '--porcelain'],
                        directory=self.working_dir.path)
     trees = []
     current = []
     while True:
         line = yield p.wait_line()
         if line is None:
             # Do not report if we only have the current directory
             if len(trees) > 1:
                 visitor.branches(CAT_WORKTREES,
                                  'vcs-git-worktrees-symbolic',
                                  not CAN_RENAME, trees)
             break
         elif not line:
             trees.append(current)
         elif line.startswith('worktree '):
             current = GPS.VCS2.Branch(
                 name='"%s"' % line[9:],  # quoted not to expand '/'
                 active=self.working_dir == GPS.File(line[9:]),
                 annotation='',
                 id='')  # unique id
         elif line.startswith('HEAD '):
             current[3] = line[5:]  # unique id
         elif line.startswith('branch '):
             current[2] = line[7:]  # details
         elif line.startswith('detached'):
             current[2] = 'detached'  # details
コード例 #2
0
def gnatpp(file):
    """
    Run gnatpp on a specific file.
    Nothing is done if the file is not an Ada file.
    """
    if file.language().lower() != 'ada':
        GPS.Logger("GNATPP").log("Not an Ada file: %s" % file.path)
        return

    sv = GPS.Project.scenario_variables()
    x_args = ['-X%s=%s' % (k, v) for k, v in sv.items()] if sv else []

    gnat_driver = gs_utils.get_gnat_driver_cmd()

    # If the GNAT driver is not found (e.g: when <target_prefix>-gnat
    # is not found), fallback on the native GNAT driver
    if not locate_exec_on_path(gnat_driver):
        gnat_driver = "gnat"

    cmd = [gnat_driver,
           'pretty',
           '-rnb',
           '-P%s' % GPS.Project.root().file().path] + x_args + [file.path]

    p = ProcessWrapper(cmd, spawn_console='')
    status, output = yield p.wait_until_terminate()

    if status != 0:
        GPS.Locations.parse(output, category='gnat pretty')
    else:
        GPS.EditorBuffer.get(file, force=True, open=True)
コード例 #3
0
    def _internal_commit_staged_files(self, visitor, args):
        """
        Execute the command `args` and pass all staged files.

        :param List(str) args: the command and its arguments
        """
        # Need to copy the list, since '_staged' will be changed below
        files = list(self._staged)
        p = ProcessWrapper(args + [f.path for f in files],
                           directory=self.working_dir.path)
        (status, output) = yield p.wait_until_terminate()
        if status:
            GPS.Console().write("%s %s" % (" ".join(args), output))
        else:
            self.stage_or_unstage_files(files, stage=False)
            visitor.success('Commit successful')
コード例 #4
0
 def _svn(self, args, block_exit=False, spawn_console=False):
     """
     Execute svn with the given arguments
     """
     return ProcessWrapper(['svn', '--non-interactive'] + args,
                           block_exit=block_exit,
                           spawn_console=spawn_console,
                           directory=self.working_dir.path)
コード例 #5
0
ファイル: gerrit.py プロジェクト: zackboll/gps
    def async_branches(self, visitor):
        p = ProcessWrapper(
            ['ssh',
             '-x',
             '-p' if self.port else '', self.port,
             self.host,
             'gerrit',
             'query',
             '--format=json',
             '--current-patch-set',
             'project:%s' % self.project,
             'status:open'], block_exit=False)
        reviews = []
        while True:
            line = yield p.wait_line()
            if line is None:
                if reviews:
                    visitor.branches(
                        CAT_REVIEWS, 'vcs-gerrit-symbolic',
                        not CAN_RENAME, reviews)
                break

            patch = json.loads(line)
            if patch and patch.get(u'subject', None) is not None:
                review = '0'
                workflow = ''
                patchset = patch[u'currentPatchSet']
                if patchset.get(u'approvals', None) is not None:
                    for a in patchset[u'approvals']:
                        if a[u'type'] == u'Workflow':
                            workflow = '|%s' % a['value']
                        elif a[u'type'] == u'Code-Review':
                            review = a['value']

                id = {'url': patch.get(u'url', ''),
                      'number': patch.get(u'number', '')}

                reviews.append(
                    ('%s: %s' % (patchset[u'author'][u'username'],
                                 patch[u'subject']),
                     False,   # not active
                     '%s%s' % (review, workflow),
                     json.dumps(id)))
コード例 #6
0
ファイル: gnatfuzz_view.py プロジェクト: AdaCore/gps
    def process_crashes(self, task):
        """Workflow to read the crashes from the fuzzing session"""

        global counter

        while self.candidate_crash_files:
            candidate = self.candidate_crash_files.pop()
            if candidate not in self.crashes:
                executable = coverage_executable()
                # We're actually launching the executable to get the
                # parameters that were passed to the crash, along with
                # the actual crash message.
                cl = [executable, candidate]
                p = ProcessWrapper(cl)
                status, output = yield p.wait_until_terminate()
                c = FuzzCrash(candidate)

                splits = candidate.split(os.sep)
                issue_dir = splits[-2]

                if issue_dir == "crashes":
                    issue_label = "Crash"
                elif issue_dir == "hangs":
                    issue_label = "Hang"
                else:
                    issue_label = "Issue"

                c.label = f"{str(counter)} ({issue_label})"
                counter += 1
                c.params = []
                # Replace this code when the output of harness programs
                # is simpler to parse.
                for line in output.splitlines():
                    if line.startswith("Parameter:"):
                        param, value = line.split("=", 1)
                        c.params.append((param, value))

                    # Very crude, need a proper parsable output for this
                    if "raised" in line:
                        _, msg = line.split("raised")
                        c.message = msg

                self.fcl.add_crash(c)
コード例 #7
0
ファイル: cvs.py プロジェクト: vpodzime/gps
    def _cvs(self, args, block_exit=False, spawn_console=False):
        """
        Execute cvs with the given arguments.

        :param List(str) args: list of arguments
        :returntype: a ProcessWrapper
        """
        return ProcessWrapper(['cvs'] + args,
                              block_exit=block_exit,
                              spawn_console=spawn_console,
                              directory=self.working_dir.path)
コード例 #8
0
def gnatpp(file):
    """
    Run gnatpp on a specific file.
    Nothing is done if the file is not an Ada file.
    """
    if file.language().lower() != 'ada':
        GPS.Logger("GNATPP").log("Not an Ada file: %s" % file.path)
        return

    p = ProcessWrapper([
        gps_utils.get_gnat_driver_cmd(), 'pretty', '-rf',
        '-P%s' % GPS.Project.root().file().path,
        GPS.Project.scenario_variables_cmd_line('-X'), file.path
    ],
                       spawn_console='')
    status, output = yield p.wait_until_terminate()

    if status != 0:
        GPS.Locations.parse(output, category='gnat pretty')
    else:
        GPS.EditorBuffer.get(file, force=True, open=True)
コード例 #9
0
ファイル: git.py プロジェクト: lupine37/gps
 def _git(self, args, block_exit=False, **kwargs):
     """
     Return git with the given arguments
     :param List(str) args: git arguments
     :param bool block_exit: if True, GPS won't exit while this process
         is running.
     :returntype: a ProcessWrapper
     """
     return ProcessWrapper(['git', '--no-pager'] + args,
                           block_exit=block_exit,
                           directory=self.working_dir.path,
                           **kwargs)
コード例 #10
0
ファイル: gnatpp.py プロジェクト: MichelKramer31/gps
def gnatpp(file):
    """
    Run gnatpp on a specific file.
    Nothing is done if the file is not an Ada file.
    """
    if file.language().lower() != 'ada':
        GPS.Logger("GNATPP").log("Not an Ada file: %s" % file.path)
        return

    p = ProcessWrapper(
        [gps_utils.get_gnat_driver_cmd(),
         'pretty',
         '-rf',
         '-P%s' % GPS.Project.root().file().path,
         GPS.Project.scenario_variables_cmd_line('-X'),
         file.path],
        spawn_console='')
    status, output = yield p.wait_until_terminate()

    if status != 0:
        GPS.Locations.parse(output, category='gnat pretty')
    else:
        GPS.EditorBuffer.get(file, force=True, open=True)
コード例 #11
0
ファイル: clearcase.py プロジェクト: anujarora1/gps
 def _cleartool(self, args, block_exit=False):
     p = ProcessWrapper(['cleartool'] + args,
                        block_exit=block_exit,
                        directory=self.working_dir.path)
     return p
コード例 #12
0
ファイル: gerrit.py プロジェクト: spanners/GNATstudio
    def async_branches(self, visitor):
        # We use -q to hide warnings which could for instance occur
        # when redirecting ports if ~/.ssh/config contains
        #   Host ...
        #      RemoteForward 3142 localhost:22

        if not self.gerrit_accessible:
            return

        p = ProcessWrapper(
            [
                'ssh',
                '-x',
                '-q',  # Hide warnings
                '-p' if self.port else '',
                self.port,
                self.host,
                'gerrit',
                'query',
                '--format=json',
                '--current-patch-set',
                'project:%s' % self.project,
                'status:open'
            ],
            block_exit=False)

        reviews = []
        while True:
            line = yield p.wait_line()
            if line is None:
                if reviews:
                    visitor.branches(CAT_REVIEWS, 'vcs-gerrit-symbolic',
                                     not CAN_RENAME, reviews)
                break

            if line.startswith('Bad port'):
                # Seems like Gerrit can't be accessed
                GPS.Console().write('Can\'t access Gerrit %s:%s\n' %
                                    (self.host, self.port))
                self.gerrit_accessible = False
                break

            patch = json.loads(line)
            if patch and patch.get(u'subject', None) is not None:
                review = '0'
                workflow = ''
                patchset = patch[u'currentPatchSet']
                if patchset.get(u'approvals', None) is not None:
                    for a in patchset[u'approvals']:
                        if a[u'type'] == u'Workflow':
                            workflow = '|%s' % a['value']
                        elif a[u'type'] == u'Code-Review':
                            review = a['value']

                id = {
                    'url': patch.get(u'url', ''),
                    'number': patch.get(u'number', '')
                }

                reviews.append((
                    '%s: %s' %
                    (patchset[u'author'][u'username'], patch[u'subject']),
                    False,  # not active
                    '%s%s' % (review, workflow),
                    json.dumps(id)))