Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_mailing_list_url_not_found(self):
"""Test whether it raises an exception when a mailing list is not found"""
httpretty.register_uri(httpretty.GET, GMANE_INVALID_LIST_URL,
status=200,
body="No such list")
client = GmaneClient()
with self.assertRaises(RepositoryError):
client.mailing_list_url('invalidlist@example.com')
def test_message(self):
"""Make sure that prints the correct error"""
e = errors.RepositoryError(cause='error cloning repository')
self.assertEqual('error cloning repository', str(e))
def test_group_gone(self):
"""Test whether the group gone exception (HTTP 410) is properly handled"""
httpretty.register_uri(httpretty.GET,
MEETUP_EVENTS_URL,
body="",
status=410)
client = MeetupClient('aaaa', max_items=2)
events = client.events('sqlpass-es')
with self.assertRaises(RepositoryError):
_ = [event for event in events]
def tearDown(self):
repo = GraalRepository('http://example.git', self.git_path)
try:
repo._exec(['git', 'branch', '-D', 'testworktree'], cwd=repo.dirpath, env=repo.gitenv)
repo._exec(['git', 'branch', '-D', 'graaltest'], cwd=repo.dirpath, env=repo.gitenv)
except RepositoryError:
pass
def prune(self):
"""Delete a working tree from disk
:param worktreepath: directory where the working tree is located
"""
GraalRepository.delete(self.worktreepath)
cmd_worktree = [GIT_EXEC_PATH, 'worktree', 'prune']
try:
self._exec(cmd_worktree, cwd=self.dirpath, env=self.gitenv)
logger.debug("Git worktree %s deleted!" % self.worktreepath)
except Exception:
cause = "Impossible to delete the worktree %s" % (self.worktreepath)
raise RepositoryError(cause=cause)
def mailing_list_url(self, mailing_list_address):
"""Get the Gmane URL that stores the given mailing list address.
:param mailing_list_address: address of the mailing list (i.e:
my-mailing-list@example.com)
:raises RepositoryError: when the given mailing list repository
is not stored by Gmane
"""
r = self.fetch(self.GMANE_LISTID_RTYPE, mailing_list_address)
if len(r.history) == 0:
cause = "%s mailing list not found in Gmane"
raise RepositoryError(cause=cause)
return r.url
def __init__(self, uri, dirpath):
gitdir = os.path.join(dirpath, 'HEAD')
if not os.path.exists(dirpath):
cause = "directory '%s' for Git repository '%s' does not exist" % (dirpath, uri)
raise RepositoryError(cause=cause)
elif not os.path.exists(gitdir):
warning = "Working directories for Git repositories no longer supported." \
"Please remove it or clone it using --mirror option."
logger.warning(warning)
cause = "directory '%s' is not a Git mirror of repository '%s'" % (dirpath, uri)
raise RepositoryError(cause=cause)
self.uri = uri
self.dirpath = dirpath
self.gitenv = {
'LANG': 'C',
'PAGER': '',
'HTTP_PROXY': os.getenv('HTTP_PROXY', ''),
'HTTPS_PROXY': os.getenv('HTTPS_PROXY', ''),
'NO_PROXY': os.getenv('NO_PROXY', ''),
'HOME': os.getenv('HOME', '')
}
cwd=cwd,
env=env)
err_thread = threading.Thread(target=self._read_stderr,
kwargs={'encoding': encoding},
daemon=True)
err_thread.start()
for line in self.proc.stdout:
yield line.decode(encoding, errors='surrogateescape')
err_thread.join()
self.proc.communicate()
self.proc.stdout.close()
self.proc.stderr.close()
except OSError as e:
err_thread.join()
raise RepositoryError(cause=str(e))
if self.proc.returncode != 0:
cause = "git command - %s (return code: %d)" % \
(self.failed_message, self.proc.returncode)
raise RepositoryError(cause=cause)
err_thread.start()
for line in self.proc.stdout:
yield line.decode(encoding, errors='surrogateescape')
err_thread.join()
self.proc.communicate()
self.proc.stdout.close()
self.proc.stderr.close()
except OSError as e:
err_thread.join()
raise RepositoryError(cause=str(e))
if self.proc.returncode != 0:
cause = "git command - %s (return code: %d)" % \
(self.failed_message, self.proc.returncode)
raise RepositoryError(cause=cause)