예제 #1
0
파일: db.py 프로젝트: HexColors60/16k-mudd
def getclass(path):
    # check cache
    if ccache.has_key(path):
        return ccache[path]

    try:
        # Remember our namespace; this will become the iclass' namespace on
        # success since execfile() modifies it.

        ccache[path] = None  # dummy value to avoid recursion

        ns = namespace.get()  # restricted execution environment
        execfile(dpath(path) + '.py', ns)
    except IOError, e:
        del ccache[path]

        if e[0] != ENOENT: raise

        # missing file.
        raise NoSuchClass, path
예제 #2
0
파일: db.py 프로젝트: ap0ught/16k-mudd
def getclass(path):
    # check cache
    if ccache.has_key(path):
        return ccache[path]

    try:
        # Remember our namespace; this will become the iclass' namespace on
        # success since execfile() modifies it.

        ccache[path] = None # dummy value to avoid recursion
        
        ns = namespace.get() # restricted execution environment
        execfile(dpath(path) + '.py', ns)
    except IOError, e:
        del ccache[path]
        
        if e[0] != ENOENT: raise

        # missing file.
        raise NoSuchClass, path
예제 #3
0
파일: db.py 프로젝트: HexColors60/16k-mudd
        except:
            util.log_exc()


def getcode(path):
    try:
        f = open(dpath(path) + '.py')
    except IOError:
        raise NoSuchObject, path
    try:
        return f.read()
    finally:
        f.close()


# Load compressed data
def load_gz():
    global gzcache
    if gzcache is None:
        gzcache = {}
        try:
            f = gzip.open('data.gz', 'r')
            gzcache = pickle.Unpickler(f).load()
            f.close()
        except:
            pass


# Shorthand for softcode.sys
soft_sys = namespace.get()['sys']
예제 #4
0
파일: db.py 프로젝트: ap0ught/16k-mudd
    # Completed ok. Clean up backup
    try: os.unlink(oldfname)
    except: pass
    # return None

# Sync cache -- write all dirty objects
def sync():
    for i in ocache.keys():
        try: ocache[i].save()
        except: util.log_exc()

def getcode(path):
    try: f = open(dpath(path) + '.py')
    except IOError: raise NoSuchObject, path
    try: return f.read()
    finally: f.close()

# Load compressed data
def load_gz():
    global gzcache
    if gzcache is None:
        gzcache = {}
        try:
            f = gzip.open('data.gz', 'r')
            gzcache = pickle.Unpickler(f).load()
            f.close()
        except: pass

# Shorthand for softcode.sys
soft_sys = namespace.get()['sys']