-
Notifications
You must be signed in to change notification settings - Fork 292
/
exceptions.py
106 lines (77 loc) · 2.46 KB
/
exceptions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
class BranchNotFoundError(ValueError):
def __init__(self, branch, repo=None):
self.branch = branch
self.repo = repo
def __str__(self):
if self.repo:
repo_str = " in repo: %s" % self.repo
else:
repo_str = ""
return "Branch '{branch}' not found{repo_str}!".format(
branch=self.branch, repo_str=repo_str)
class GitError(RuntimeError):
pass
class BootstrapError(RuntimeError):
pass
class ConfigError(RuntimeError):
"""
Meant to be used when an invalid config entry is found.
"""
pass
class CommandFailedError(Exception):
"""
Exception thrown on command failure
"""
def __init__(self, command, exitstatus, node=None):
self.command = command
self.exitstatus = exitstatus
self.node = node
def __str__(self):
return "Command failed on {node} with status {status}: {cmd!r}".format(
node=self.node,
status=self.exitstatus,
cmd=self.command,
)
class CommandCrashedError(Exception):
"""
Exception thrown on crash
"""
def __init__(self, command):
self.command = command
def __str__(self):
return "Command crashed: {command!r}".format(
command=self.command,
)
class ConnectionLostError(Exception):
"""
Exception thrown when the connection is lost
"""
def __init__(self, command, node=None):
self.command = command
self.node = node
def __str__(self):
node_str = 'to %s ' % self.node if self.node else ''
return "SSH connection {node_str}was lost: {command!r}".format(
node_str=node_str,
command=self.command,
)
class ScheduleFailError(RuntimeError):
def __init__(self, message, name=None):
self.message = message
self.name = name
def __str__(self):
return "Scheduling {name} failed: {msg}".format(
name=self.name,
msg=self.message,
).replace(' ', ' ')
class VersionNotFoundError(Exception):
def __init__(self, url):
self.url = url
def __str__(self):
return "Failed to fetch package version from %s" % self.url
class UnsupportedPackageTypeError(Exception):
def __init__(self, node):
self.node = node
def __str__(self):
return "os.package_type {pkg_type!r} on {node}".format(
node=self.node, pkg_type=self.node.os.package_type)