Mercurial > code > home > repos > reposync
comparison sync.py @ 2:22ccc05756de
don't waste time scanning repos that appear to have no recent activity
Ignore-this: 9a29d293662729aa46d775c4b5d31146
author | drewp@bigasterisk.com |
---|---|
date | Tue, 08 Jan 2013 23:41:13 -0800 |
parents | 1da34eecdfd8 |
children | 4077903a9520 |
comparison
equal
deleted
inserted
replaced
1:1da34eecdfd8 | 2:22ccc05756de |
---|---|
8 class Project(object): | 8 class Project(object): |
9 def __init__(self, config, gh, name): | 9 def __init__(self, config, gh, name): |
10 self.config = config | 10 self.config = config |
11 self.gh = gh | 11 self.gh = gh |
12 self.name = name | 12 self.name = name |
13 | |
14 def darcsTime(self): | |
15 j = os.path.join | |
16 darcsPriv = j(self.config['darcsDir'], self.name, '_darcs') | |
17 for n in ['inventory', 'hashed_inventory']: | |
18 if os.path.exists(j(darcsPriv, n)): | |
19 return os.path.getmtime(j(darcsPriv, n)) | |
20 raise ValueError("can't find a darcs time") | |
13 | 21 |
14 def gitDir(self): | 22 def gitDir(self): |
15 gitDir = os.path.join(self.config['gitSyncDir'], self.name) | 23 gitDir = os.path.join(self.config['gitSyncDir'], self.name) |
16 try: | 24 try: |
17 os.mkdir(gitDir) | 25 os.mkdir(gitDir) |
54 # curl -u drewp https://api.github.com/authorizations -d '{"scopes":["repo"]}' | 62 # curl -u drewp https://api.github.com/authorizations -d '{"scopes":["repo"]}' |
55 # from http://developer.github.com/v3/oauth/#oauth-authorizations-api | 63 # from http://developer.github.com/v3/oauth/#oauth-authorizations-api |
56 gh = Github(config['gitHubToken']).get_user() | 64 gh = Github(config['gitHubToken']).get_user() |
57 | 65 |
58 for proj in os.listdir(config['darcsDir']): | 66 for proj in os.listdir(config['darcsDir']): |
59 if 'repo' not in proj: | |
60 continue | |
61 if not os.path.isdir(os.path.join(config['darcsDir'], proj)): | 67 if not os.path.isdir(os.path.join(config['darcsDir'], proj)): |
62 continue | 68 continue |
63 try: | 69 try: |
64 p = Project(config, gh, proj) | 70 p = Project(config, gh, proj) |
71 | |
72 if p.darcsTime() < time.time() - 86400*config['tooOldDays']: | |
73 continue | |
74 | |
65 log.info("syncing %s" % proj) | 75 log.info("syncing %s" % proj) |
66 p.syncToLocalGit() | 76 p.syncToLocalGit() |
67 p.makeGitHubRepo() | 77 p.makeGitHubRepo() |
68 p.pushToGitHub() | 78 p.pushToGitHub() |
69 except Exception, e: | 79 except Exception, e: |