Example #1
0
def test_iteration_error_stderr():
  p = Sh('cat', 'DOES-NOT-EXIST')
  try:
    p.next()
    assert False and 'Expected ShError'
  except ShError, e:
    assert 'cat: DOES-NOT-EXIST: No such file or directory\n' == e.stderr
Example #2
0
def test_iteration_error_stdout_no_stderr():
  p = Sh('bash', '-c', 'echo hello ; false')
  assert 'hello' == p.next()
  try:
    p.next()
    assert False and 'Expected ShError'
  except ShError, e:
    pass
Example #3
0
def test_iteration_no_newline_no_error():
  x = Sh('printf', 'hello')
  assert 'hello' == x.next()
  try:
    x.next()
    assert False and 'Expected StopIteration'
  except StopIteration:
    pass
Example #4
0
def test_iteration_error_no_stderr():
  p = Sh('false')
  try:
    p.next()
    assert False and 'Expected ShError'
  except ShError, e:
    assert 1 == e.returncode
    assert ('false',) == e.cmd
    assert '' == e.stderr
Example #5
0
def test_iteration_many_lines_no_error():
  x = Sh('bash', '-c', 'for i in {1..1000}; do echo hello; done')
  for i in xrange(1000):
    assert 'hello' == x.next()
  try:
    x.next()
    assert False and 'Expected StopIteration'
  except StopIteration:
    pass
Example #6
0
 def _bla_dir(self, entry, entry_path):
     if entry == "Sample":
         Sh.rmtree(entry_path)
         return True
     if not self.is_safe(entry):
         n = Dir(self._repo_path, entry, self._iface)
         n.fate()
         return True
     if not self._good_place(entry_path):
         Sh.mv(entry_path, self._repo_path)
         return True
     return False
Example #7
0
 def _bla(self):
     need_redo = False
     content = self.__get_content()
     if content:
         for (entry, entry_path) in content:
             if os.path.isdir(entry_path):
                 need_redo |= self._bla_dir(entry, entry_path)
             if os.path.isfile(entry_path):
                 need_redo |= self._bla_file(entry, entry_path)
     else:
         Sh.rmtree(self._path)
         return False
     return need_redo
Example #8
0
 def add(self, srt):
     if not self._iface.add(self.serie, self.episode.season, self.episode.num):
         return
     destination_path = os.path.join(self._repo_path, self._serie)
     Sh.mkdir(destination_path)
     Sh.mv(self._path, os.path.join(self._repo_path,
                 destination_path, "%s.%s.%s" % (self._serie, self._episode, self._ext)))
     Sh.mv(srt.path, os.path.join(self._repo_path,
                 destination_path, "%s.%s.%s" % (self._serie, self._episode, srt.ext)))
Example #9
0
 def fate(self):
     Sh.rmtree(self._path)
Example #10
0
 def fate(self):
     Sh.unzip(self._path, self._repo_path)
     Sh.rm(self._path)
     return True
Example #11
0
 def fate(self):
     Sh.rm(self._path)
     return False
Example #12
0
 def fate(self):
     if not self._good_place(self._path):
         Sh.mv(self._path, self._repo_path)
         return True
     return False