comparison repo_local_status.py @ 21:cb71722bb75c

use pipenv
author drewp@bigasterisk.com
date Tue, 29 Mar 2022 21:13:48 -0700
parents b59912649fc4
children b9fe6d26b3fa
comparison
equal deleted inserted replaced
20:b59912649fc4 21:cb71722bb75c
39 Triple = Tuple[Identifier, Identifier, Identifier] 39 Triple = Tuple[Identifier, Identifier, Identifier]
40 EX = Namespace('http://example.com/') # todo 40 EX = Namespace('http://example.com/') # todo
41 41
42 HG_SYNC = Gauge('hg_sync', 'sync passes to hg') 42 HG_SYNC = Gauge('hg_sync', 'sync passes to hg')
43 43
44 _venv = None
45
44 46
45 @inlineCallbacks 47 @inlineCallbacks
46 def runHg(cwd, args): 48 def runHg(cwd, args):
49 global _venv
50 if _venv is None:
51 _venv = yield getProcessOutput('pipenv', ['--venv'])
52 _venv = _venv.decode('ascii').strip()
53
47 if args[0] not in ['push']: 54 if args[0] not in ['push']:
48 args.extend(['-T', 'json']) 55 args.extend(['-T', 'json'])
49 j = yield getProcessOutput('/usr/local/bin/hg', args, path=cwd) 56 j = yield getProcessOutput(_venv + '/bin/hg', ['--cwd', str(cwd)] + args, env={'LANG': 'C.UTF-8'})
50 returnValue(json.loads(j) if j else None) 57 returnValue(json.loads(j) if j else None)
51 58
52 59
53 # merge this into setToGraph 60 # merge this into setToGraph
54 def replaceContext(pg: PatchableGraph, ctx: URIRef, newTriples: Set[Triple]): 61 def replaceContext(pg: PatchableGraph, ctx: URIRef, newTriples: Set[Triple]):
110 117
111 118
112 def uriForHgNode(n: str) -> URIRef: 119 def uriForHgNode(n: str) -> URIRef:
113 return URIRef(f'http://bigasterisk.com/hg/node/{n}') 120 return URIRef(f'http://bigasterisk.com/hg/node/{n}')
114 121
122
115 def uriForHgPhase(phase: str) -> URIRef: 123 def uriForHgPhase(phase: str) -> URIRef:
116 return URIRef(f'http://bigasterisk.com/hg/phase/{phase}') 124 return URIRef(f'http://bigasterisk.com/hg/phase/{phase}')
125
117 126
118 @inlineCallbacks 127 @inlineCallbacks
119 def writeLatestHgCommit(graph, repo): 128 def writeLatestHgCommit(graph, repo):
120 rows = yield runHg(repo.path, ['log', '--limit', '1']) 129 rows = yield runHg(repo.path, ['log', '--limit', '1'])
121 commit = rows[0] 130 commit = rows[0]