~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/util.py

  • Committer: William Grant
  • Date: 2010-02-11 09:09:53 UTC
  • Revision ID: grantw@unimelb.edu.au-20100211090953-592dk5jruwdg1qrq
Declare appropriate tabs on the rest of the views.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
import sys
26
26
import stat
27
27
 
 
28
class IVLEError(Exception):
 
29
    """Legacy general IVLE exception.
 
30
 
 
31
    This is the old "standard" exception class for IVLE errors. It is only
 
32
    used in fileservice, and should not be used in any new code.
 
33
    """
 
34
 
 
35
    message = None
 
36
 
 
37
    def __init__(self, httpcode, message=None):
 
38
        self.httpcode = httpcode
 
39
        self.message = message
 
40
        self.args = (httpcode, message)
 
41
 
28
42
class IVLEJailError(Exception):
29
43
    """Exception proxying an in-jail error.
30
44
 
183
197
        # Incomplete
184
198
        return count
185
199
 
 
200
def object_to_dict(attrnames, obj):
 
201
    """Convert an object into a dictionary.
 
202
 
 
203
    This takes a shallow copy of the object.
 
204
 
 
205
    @param attrnames: Set (or iterable) of names of attributes to be copied
 
206
                      into the dictionary. (We don't auto-lookup, because this
 
207
                      function needs to be used on magical objects).
 
208
    """
 
209
    return dict((k, getattr(obj, k))
 
210
        for k in attrnames if not k.startswith('_'))
 
211
 
186
212
def safe_rmtree(path, ignore_errors=False, onerror=None):
187
213
    """Recursively delete a directory tree.
188
214