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
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
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
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
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
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
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
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)))
def fate(self): Sh.rmtree(self._path)
def fate(self): Sh.unzip(self._path, self._repo_path) Sh.rm(self._path) return True
def fate(self): Sh.rm(self._path) return False
def fate(self): if not self._good_place(self._path): Sh.mv(self._path, self._repo_path) return True return False