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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
# Copyright (C) 2008 Novell Inc. All rights reserved.
# This program is free software; it may be used, copied, modified
# and distributed under the terms of the GNU General Public Licence,
# either version 2, or (at your option) any later version.
class OscBaseError(Exception):
def __init__(self, args=()):
Exception.__init__(self)
self.args = args
def __str__(self):
return ''.join(self.args)
class UserAbort(OscBaseError):
"""Exception raised when the user requested abortion"""
class ConfigError(OscBaseError):
"""Exception raised when there is an error in the config file"""
def __init__(self, msg, fname):
OscBaseError.__init__(self)
self.msg = msg
self.file = fname
class ConfigMissingApiurl(ConfigError):
"""Exception raised when a apiurl does not exist in the config file"""
def __init__(self, msg, fname, url):
ConfigError.__init__(self, msg, fname)
self.url = url
class APIError(OscBaseError):
"""Exception raised when there is an error in the output from the API"""
def __init__(self, msg):
OscBaseError.__init__(self)
self.msg = msg
class NoConfigfile(OscBaseError):
"""Exception raised when osc's configfile cannot be found"""
def __init__(self, fname, msg):
OscBaseError.__init__(self)
self.file = fname
self.msg = msg
class ExtRuntimeError(OscBaseError):
"""Exception raised when there is a runtime error of an external tool"""
def __init__(self, msg, fname):
OscBaseError.__init__(self)
self.msg = msg
self.file = fname
class ServiceRuntimeError(OscBaseError):
"""Exception raised when the execution of a source service failed"""
def __init__(self, msg):
OscBaseError.__init__(self)
self.msg = msg
class WrongArgs(OscBaseError):
"""Exception raised by the cli for wrong arguments usage"""
class WrongOptions(OscBaseError):
"""Exception raised by the cli for wrong option usage"""
#def __str__(self):
# s = 'Sorry, wrong options.'
# if self.args:
# s += '\n' + self.args
# return s
class NoWorkingCopy(OscBaseError):
"""Exception raised when directory is neither a project dir nor a package dir"""
class NotMissing(OscBaseError):
"""Exception raised when link target should not exist, but it does"""
class WorkingCopyWrongVersion(OscBaseError):
"""Exception raised when working copy's .osc/_osclib_version doesn't match"""
class WorkingCopyOutdated(OscBaseError):
"""Exception raised when the working copy is outdated.
It takes a tuple with three arguments: path to wc,
revision that it has, revision that it should have.
"""
def __str__(self):
return ('Working copy \'%s\' is out of date (rev %s vs rev %s).\n'
'Looks as if you need to update it first.' \
% (self.args[0], self.args[1], self.args[2]))
class PackageError(OscBaseError):
"""Base class for all Package related exceptions"""
def __init__(self, prj, pac):
OscBaseError.__init__(self)
self.prj = prj
self.pac = pac
class WorkingCopyInconsistent(PackageError):
"""Exception raised when the working copy is in an inconsistent state"""
def __init__(self, prj, pac, dirty_files, msg):
PackageError.__init__(self, prj, pac)
self.dirty_files = dirty_files
self.msg = msg
class LinkExpandError(PackageError):
"""Exception raised when source link expansion fails"""
def __init__(self, prj, pac, msg):
PackageError.__init__(self, prj, pac)
self.msg = msg
class OscIOError(OscBaseError):
def __init__(self, e, msg):
OscBaseError.__init__(self)
self.e = e
self.msg = msg
class PackageNotInstalled(OscBaseError):
"""
Exception raised when a package is not installed on local system
"""
def __init__(self, pkg):
OscBaseError.__init__(self, (pkg,))
def __str__(self):
return 'Package %s is required for this operation' % self.args
class SignalInterrupt(Exception):
"""Exception raised on SIGTERM and SIGHUP."""
class PackageExists(PackageError):
"""
Exception raised when a local object already exists
"""
def __init__(self, prj, pac, msg):
PackageError.__init__(self, prj, pac)
self.msg = msg
class PackageMissing(PackageError):
"""
Exception raised when a local object doesn't exist
"""
def __init__(self, prj, pac, msg):
PackageError.__init__(self, prj, pac)
self.msg = msg
class PackageFileConflict(PackageError):
"""
Exception raised when there's a file conflict.
Conflict doesn't mean an unsuccessfull merge in this context.
"""
def __init__(self, prj, pac, file, msg):
PackageError.__init__(self, prj, pac)
self.file = file
self.msg = msg
class PackageInternalError(PackageError):
def __init__(self, prj, pac, msg):
PackageError.__init__(self, prj, pac)
self.msg = msg
# vim: sw=4 et
|