示例#1
0
    def _get_repo(self, name):
        root = repository_path(name)
        if os.path.isdir(root):
            repo = GitRepoManager()
            repo.open_repo(root)

            return repo
示例#2
0
文件: func.py 项目: NMGRL/pychron
def get_review_status(record):
    ms = 0
    ritems = []
    root = repository_path(record.repository_identifier)
    if os.path.isdir(root):
        repo = Repo(root)
        for m, func in (('blanks', is_blank_reviewed),
                        ('intercepts', is_intercepts_reviewed),
                        ('icfactors', is_icfactors_reviewed)):
            p = analysis_path(record, record.repository_identifier, modifier=m)
            if os.path.isfile(p):
                with open(p, 'r') as rfile:
                    obj = json.load(rfile)
                    date = repo.git.log('-1', '--format=%cd', p)
                    items = func(obj, date)
                    if items:
                        if reviewed(items):
                            ms += 1
                        ritems.extend(items)

        # setattr(record, '{}_review_status'.format(m), (reviewed, date))
    record.review_items = ritems
    ret = 'Intermediate'  # intermediate
    if not ms:
        ret = 'Default'  # default
    elif ms == 3:
        ret = 'All'  # all

    record.review_status = ret
示例#3
0
    def _get_repo(self, name):
        root = repository_path(name)
        if os.path.isdir(root):
            repo = GitRepoManager()
            repo.open_repo(root)

            return repo
示例#4
0
 def load_spectrometer_parameters(self, spec_sha):
     if spec_sha:
         name = add_extension(spec_sha, '.json')
         p = repository_path(self.repository_identifier, name)
         sd = get_spec_sha(p)
         self.source_parameters = sd['spectrometer']
         self.gains = sd['gains']
         self.deflections = sd['deflections']
示例#5
0
 def load_spectrometer_parameters(self, spec_sha):
     if spec_sha:
         name = add_extension(spec_sha, '.json')
         p = repository_path(self.repository_identifier, name)
         sd = get_spec_sha(p)
         self.source_parameters = sd['spectrometer']
         self.gains = sd['gains']
         self.deflections = sd['deflections']
示例#6
0
def get_frozen_flux(repo, irradiation):
    path = repository_path(repo, '{}.json'.format(irradiation))

    fd = {}
    if path:
        fd = dvc_load(path)
        for fi in fd.values():
            fi['j'] = ufloat(*fi['j'], tag='J')
    return fd
示例#7
0
def get_frozen_flux(repo, irradiation):
    path = repository_path(repo, '{}.json'.format(irradiation))

    fd = {}
    if path:
        fd = dvc_load(path)
        for fi in fd.values():
            fi['j'] = ufloat(*fi['j'], tag='J')
    return fd
示例#8
0
文件: func.py 项目: NMGRL/pychron
def push_repositories(ps, remote='origin', branch='master', quiet=True):
    for p in ps:
        pp = repository_path(p)
        # repo = Repo(pp)
        repo = GitRepoManager()
        repo.open_repo(pp)

        if repo.smart_pull(remote=remote, branch=branch, quiet=quiet):
            repo.push(remote=remote, branch=branch)
示例#9
0
    def _fetch(self):
        period = 60
        while 1:
            for name in list_local_repos():
                r = Repo(repository_path(name))
                try:
                    r.git.fetch()
                except GitCommandError as e:
                    self.warning('error examining {}. {}'.format(name, e))
                time.sleep(1)

            time.sleep(period)
示例#10
0
    def _fetch(self):
        period = 60
        while 1:
            for name in list_local_repos():
                r = Repo(repository_path(name))
                try:
                    r.git.fetch()
                except GitCommandError as e:
                    self.warning('error examining {}. {}'.format(name, e))
                time.sleep(1)

            time.sleep(period)
示例#11
0
def list_local_repos():
    for i in os.listdir(paths.repository_dataset_dir):
        if i.startswith('.'):
            continue
        elif i.startswith('~'):
            continue

        d = repository_path(i)
        if os.path.isdir(d):
            gd = os.path.join(d, '.git')
            if os.path.isdir(gd):
                r = Repo(d)

                yield i, r.active_branch.name
示例#12
0
文件: func.py 项目: NMGRL/pychron
def find_interpreted_age_path(idn, repositories, prefixlen=3):
    prefix = idn[:prefixlen]
    suffix = '{}*.ia.json'.format(idn[prefixlen:])
    # ret = []
    # for e in repositories:
    #     pathname = os.path.join(paths.repository_dataset_dir,
    #                             e, prefix, 'ia', suffix)
    #     ps = glob.glob(pathname)
    #     if ps:
    #         ret.extend(ps)

    ret = [p for repo in repositories
           for p in glob.glob(repository_path(repo, prefix, 'ia', suffix))]
    return ret
示例#13
0
文件: func.py 项目: NMGRL/pychron
def repository_has_staged(ps, remote='origin', branch='master'):
    if not hasattr(ps, '__iter__'):
        ps = (ps,)

    changed = []
    # repo = GitRepoManager()
    for p in ps:
        pp = repository_path(p)
        repo = Repo(pp)

        if repo.git.log('{}/{}..HEAD'.format(remote, branch), '--oneline'):
            changed.append(p)

    return changed
示例#14
0
    def update(self, fetch=True):
        name = self.name
        p = repository_path(name)
        try:
            try:
                a, b = ahead_behind(p, fetch=fetch)
            except InvalidGitRepositoryError:
                return True

            self.ahead = a
            self.behind = b
            self.status = '{},{}'.format(a, b)
            self.refresh_needed = True
            return True
        except GitCommandError:
            pass
示例#15
0
    def update(self, fetch=True):
        name = self.name
        p = repository_path(name)
        try:
            try:
                a, b = ahead_behind(p, fetch=fetch)
            except InvalidGitRepositoryError:
                return True

            self.ahead = a
            self.behind = b
            self.status = '{},{}'.format(a, b)
            self.refresh_needed = True
            return True
        except GitCommandError:
            pass
示例#16
0
    def perform(self, event):
        from git import Repo
        from git.exc import InvalidGitRepositoryError
        from pychron.paths import paths
        remote = 'origin'
        branch = 'master'
        repos = []
        for d in os.listdir(paths.repository_dataset_dir):
            if d.startswith('.') or d.startswith('~'):
                continue

            try:
                r = Repo(repository_path(d))
            except InvalidGitRepositoryError:
                continue
            repos.append(r)

        n = len(repos)
        pd = myProgressDialog(max=n - 1, can_cancel=True, can_ok=False)
        pd.open()
        shared = False
        for r in repos:
            pd.change_message('Fetch {}'.format(os.path.basename(
                r.working_dir)))
            c = r.git.log('{}/{}..HEAD'.format(remote, branch), '--oneline')
            if c:

                r.git.pull()

                d = os.path.basename(r.working_dir)
                if confirm(None,
                           'Share changes made to {}.\n\n{}'.format(d,
                                                                    c)) == YES:
                    r.git.push(remote, branch)
                    shared = True

        msg = 'Changes successfully shared' if shared else 'No changes to share'
        information(None, msg)
示例#17
0
    def initialize(self, repository, pull=True):
        """
        setup git repos.

        repositories are guaranteed to exist. The automated run factory clones the required projects
        on demand.

        :return:
        """
        self.debug('^^^^^^^^^^^^^ Initialize DVCPersister {} pull={}'.format(repository, pull))

        self.dvc.initialize()

        repository = format_repository_identifier(repository)
        self.active_repository = repo = GitRepoManager()

        root = repository_path(repository)
        repo.open_repo(root)

        remote = 'origin'
        if repo.has_remote(remote) and pull:
            self.info('pulling changes from repo: {}'.format(repository))
            self.active_repository.pull(remote=remote, use_progress=False)
示例#18
0
文件: actions.py 项目: NMGRL/pychron
    def perform(self, event):
        from git import Repo
        from git.exc import InvalidGitRepositoryError
        from pychron.paths import paths
        remote = 'origin'
        branch = 'master'
        repos = []
        for d in os.listdir(paths.repository_dataset_dir):
            if d.startswith('.') or d.startswith('~'):
                continue

            try:
                r = Repo(repository_path(d))
            except InvalidGitRepositoryError:
                continue
            repos.append(r)

        n = len(repos)
        pd = myProgressDialog(max=n - 1,
                              can_cancel=True,
                              can_ok=False)
        pd.open()
        shared = False
        for r in repos:
            pd.change_message('Fetch {}'.format(os.path.basename(r.working_dir)))
            c = r.git.log('{}/{}..HEAD'.format(remote, branch), '--oneline')
            if c:

                r.git.pull()

                d = os.path.basename(r.working_dir)
                if confirm(None, 'Share changes made to {}.\n\n{}'.format(d, c)) == YES:
                    r.git.push(remote, branch)
                    shared = True

        msg = 'Changes successfully shared' if shared else 'No changes to share'
        information(None, msg)