comparison buttercup/source.py @ 52:b717de8b384f

py3
author Jeff Hammel <k0scist@gmail.com>
date Tue, 03 Nov 2020 07:51:52 -0800
parents 048e391423a1
children
comparison
equal deleted inserted replaced
51:59969aed59fb 52:b717de8b384f
1 """ 1 """
2 VCS sources for the flower project 2 VCS sources for the flower project
3 """ 3 """
4 4
5 import os 5 import os
6 try: 6 from subprocess import check_call as call
7 from subprocess import check_call as call 7
8 except ImportError:
9 from subprocess import call
10 8
11 class Source(object): 9 class Source(object):
12 """abstract base class for VCS source""" 10 """abstract base class for VCS source"""
13 def __init__(self, uri, srcdir=None): 11 def __init__(self, uri, srcdir=None):
14 self.uri = uri 12 self.uri = uri
40 assert os.path.exists(hgdir), "Not an hg directory: %s" % hgdir 38 assert os.path.exists(hgdir), "Not an hg directory: %s" % hgdir
41 try: 39 try:
42 call(['hg', 'pull'], cwd=self.directory()) 40 call(['hg', 'pull'], cwd=self.directory())
43 call(['hg', 'update'], cwd=self.directory()) 41 call(['hg', 'update'], cwd=self.directory())
44 except: 42 except:
45 print 'Directory: %s' % self.directory() 43 print('Directory: %s' % self.directory())
46 raise 44 raise
47 else: 45 else:
48 if not os.path.exists(self.srcdir): 46 if not os.path.exists(self.srcdir):
49 os.makedirs(self.srcdir) 47 os.makedirs(self.srcdir)
50 call(['hg', 'clone', self.uri], cwd=self.srcdir) 48 call(['hg', 'clone', self.uri], cwd=self.srcdir)