Exemplo n.º 1
0
 def ensure(self, *args, **kwargs):
     """ ensure that an args-joined path exists (by default as
         a file). If you specify a keyword argument 'dir=True'
         then the path is forced to be a directory path.
     """
     if getattr(self, 'rev', None) is not None:
         raise py.error.EINVAL(self, "revisions are immutable")
     target = self.join(*args)
     dir = kwargs.get('dir', 0) 
     for x in target.parts(reverse=True): 
         if x.check(): 
             break 
     else: 
         raise py.error.ENOENT(target, "has not any valid base!") 
     if x == target: 
         if not x.check(dir=dir): 
             raise dir and py.error.ENOTDIR(x) or py.error.EISDIR(x) 
         return x 
     tocreate = target.relto(x) 
     basename = tocreate.split(self.sep, 1)[0]
     tempdir = py.path.local.mkdtemp()
     try:    
         tempdir.ensure(tocreate, dir=dir) 
         cmd = 'svn import -m "%s" "%s" "%s"' % (
                 "ensure %s" % self._escape(tocreate), 
                 self._escape(tempdir.join(basename)), 
                 x.join(basename)._encodedurl())
         process.cmdexec(cmd) 
         self._lsnorevcache.delentry(x.strpath)  # !!! 
     finally:    
         tempdir.remove() 
     return target
Exemplo n.º 2
0
    def remove(self, rec=1, msg='removed by py lib invocation'):
        """ remove a file or directory (or a directory tree if rec=1) with
checkin message msg."""
        if self.rev is not None:
            raise py.error.EINVAL(self, "revisions are immutable")
        process.cmdexec('svn rm -m "%s" "%s"' %(msg, self._escape(self)))
        self._lsnorevcache.delentry(self.dirpath().strpath)
Exemplo n.º 3
0
 def copy(self, target, msg='copied by py lib invocation'):
     """ copy path to target with checkin message msg."""
     if getattr(target, 'rev', None) is not None:
         raise py.error.EINVAL(target, "revisions are immutable")
     process.cmdexec('svn copy -m "%s" "%s" "%s"' %(msg, 
                                             self._escape(self), self._escape(target)))
     self._lsnorevcache.delentry(target.dirpath().strpath)
Exemplo n.º 4
0
 def test_simple_error_exact_status(self):
     try:
         cmdexec('exit 1')
     except cmdexec.Error:
         e = exvalue()
         assert e.status == 1
         assert py.builtin._istext(e.out)
         assert py.builtin._istext(e.err)
Exemplo n.º 5
0
 def test_simple_error_exact_status(self):
     try:
         cmdexec('exit 1')
     except cmdexec.Error:
         e = exvalue()
         assert e.status == 1
         assert py.builtin._istext(e.out)
         assert py.builtin._istext(e.err)
Exemplo n.º 6
0
 def test_err(self):
     try:
         cmdexec('echoqweqwe123 hallo')
         raise AssertionError, "command succeeded but shouldn't"
     except cmdexec.Error, e:
         assert hasattr(e, 'err')
         assert hasattr(e, 'out')
         assert e.err or e.out
Exemplo n.º 7
0
 def test_err(self):
     try:
         cmdexec('echoqweqwe123 hallo')
         raise AssertionError("command succeeded but shouldn't")
     except cmdexec.Error:
         e = exvalue()
         assert hasattr(e, 'err')
         assert hasattr(e, 'out')
         assert e.err or e.out
Exemplo n.º 8
0
 def generate(self, storedir=None, target='ps'):
     source = self.get_source()
     if target is None:
         return source  # unprocessed
     if storedir is None:
         storedir = udir
     pdot = storedir.join('%s.dot' % self.graphname)
     pdot.write(source)
     ptarget = pdot.new(ext=target)
     cmdexec('dot -T%s %s>%s' % (target, str(pdot), str(ptarget)))
     return ptarget
Exemplo n.º 9
0
 def generate(self, storedir=None, target="ps"):
     source = self.get_source()
     if target is None:
         return source  # unprocessed
     if storedir is None:
         storedir = udir
     pdot = storedir.join("%s.dot" % self.graphname)
     pdot.write(source)
     ptarget = pdot.new(ext=target)
     cmdexec("dot -T%s %s>%s" % (target, str(pdot), str(ptarget)))
     return ptarget
Exemplo n.º 10
0
 def _cmdexec(self, cmd):
     try:
         out = process.cmdexec(cmd)
     except py.process.cmdexec.Error, e:
         if (e.err.find('File Exists') != -1
                 or e.err.find('File already exists') != -1):
             raise py.error.EEXIST(self)
         raise
Exemplo n.º 11
0
 def _cmdexec(self, cmd):
     try:
         out = process.cmdexec(cmd)
     except py.process.cmdexec.Error, e:
         if (e.err.find('File Exists') != -1 or
                         e.err.find('File already exists') != -1):
             raise py.error.EEXIST(self)
         raise
Exemplo n.º 12
0
 def _cmdexec(self, cmd):
     try:
         out = process.cmdexec(cmd)
     except py.process.cmdexec.Error:
         e = sys.exc_info()[1]
         if e.err.find("File Exists") != -1 or e.err.find("File already exists") != -1:
             raise py.error.EEXIST(self)
         raise
     return out
Exemplo n.º 13
0
 def _cmdexec(self, cmd):
     try:
         out = process.cmdexec(cmd)
     except py.process.cmdexec.Error:
         e = sys.exc_info()[1]
         if (e.err.find("File Exists") != -1
                 or e.err.find("File already exists") != -1):
             raise py.error.EEXIST(self)
         raise
     return out
Exemplo n.º 14
0
 def _svnwrite(self, cmd, *args):
     l = ['svn %s' % cmd]
     args = ['"%s"' % self._escape(item) for item in args]
     l.extend(args)
     l.append('"%s"' % self._encodedurl())
     # fixing the locale because we can't otherwise parse
     string = svncommon.fixlocale() + " ".join(l)
     if DEBUG:
         print "execing", string
     try:
         out = process.cmdexec(string)
     except py.process.cmdexec.Error, e:
         if (e.err.find('File Exists') != -1 or
                         e.err.find('File already exists') != -1):
             raise py.error.EEXIST(self)
         raise
Exemplo n.º 15
0
 def test_simple(self):
     out = cmdexec('echo hallo')
     assert out.strip() == 'hallo'
Exemplo n.º 16
0
 def test_simple_error_exact_status(self):
     try:
         cmdexec('exit 1')
     except cmdexec.Error, e:
         assert e.status == 1
Exemplo n.º 17
0
 def test_simple_newline(self):
     import sys
     out = cmdexec(r"""%s -c "print ('hello')" """ % sys.executable)
     assert out == 'hello\n'
     assert py.builtin._istext(out)
Exemplo n.º 18
0
 def test_simple(self):
     out = cmdexec('echo hallo')
     assert out.strip() == 'hallo'
     assert py.builtin._istext(out)
Exemplo n.º 19
0
 def test_simple(self):
     out = cmdexec('echo hallo')
     assert out.strip() == 'hallo'
     assert py.builtin._istext(out)
Exemplo n.º 20
0
 def test_simple_newline(self):
     import sys
     out = cmdexec(r"""%s -c "print ('hello')" """ % sys.executable)
     assert out == 'hello\n'
     assert py.builtin._istext(out)