Exemple #1
0
    def update(self):
        """Updates the statistics and cache from the mRSL files"""

        self.__gridstat_dict = {}

        # Cache and timestamp dirs

        root_dir = self.__configuration.mrsl_files_dir
        buildcache_file = self.__configuration.gridstat_files_dir\
             + 'buildcache.pck'
        buildtimestamp_file = self.__configuration.gridstat_files_dir\
             + 'buildcache.timestamp'

        # We lock the buildcache, to make sure that only one vgrid is
        # updated at a time

        if os.path.exists(buildcache_file):
            try:
                file_handle = open(buildcache_file, 'r+w')
                fcntl.flock(file_handle.fileno(), fcntl.LOCK_EX)
                buildcache_dict = py_pickle.load(file_handle)
            except Exception, err:
                msg = 'gridstat::update(): %s could not be loaded! %s'\
                     % (buildcache_file, err)
                print msg
                self.__logger.error(msg)
                return False
Exemple #2
0
    def update(self):
        """Updates the statistics and cache from the mRSL files"""

        self.__gridstat_dict = {}

        # Cache and timestamp dirs

        root_dir = self.__configuration.mrsl_files_dir
        buildcache_file = self.__configuration.gridstat_files_dir\
             + 'buildcache.pck'
        buildtimestamp_file = self.__configuration.gridstat_files_dir\
             + 'buildcache.timestamp'

        # We lock the buildcache, to make sure that only one vgrid is
        # updated at a time

        if os.path.exists(buildcache_file):
            try:
                file_handle = open(buildcache_file, 'r+w')
                fcntl.flock(file_handle.fileno(), fcntl.LOCK_EX)
                buildcache_dict = py_pickle.load(file_handle)
            except Exception, err:
                msg = 'gridstat::update(): %s could not be loaded! %s'\
                     % (buildcache_file, err)
                print msg
                self.__logger.error(msg)
                return False
Exemple #3
0
import os
import sys

from shared.serial import pickle

if len(sys.argv) < 2:
    print 'Usage: %s PATH' % sys.argv[0]
    print 'Edit pickled object in file PATH'
    sys.exit(1)

dirty = False
path = sys.argv[1]
print "opening pickle in %s" % path
pickle_fd = open(path, 'rb+')
obj = pickle.load(pickle_fd)
print "pickled object loaded as 'obj'"
while True:
    command = raw_input("Enter command: ")
    command = command.lower().strip()
    if command in ['o', 'open']:
        path = raw_input("Path to open: ")
        pickle_fd = open(path, 'rb+')
        obj = pickle.load(pickle_fd)
    elif command in ['h', 'help']:
        print "Valid commands include:"
        print "(d)isplay to display the opened pickled object"
        print "(e)dit to edit the opened pickled object"
        print "(o)pen to open a new pickle file"
        print "(c)lose to close the opened pickled object"
        print "(q)uit to quit pickle editor"
Exemple #4
0
import os
import sys

from shared.serial import pickle


if len(sys.argv) < 2:
    print 'Usage: %s PATH' % sys.argv[0]
    print 'Edit pickled object in file PATH'
    sys.exit(1)

dirty = False
path = sys.argv[1]
print "opening pickle in %s" % path
pickle_fd = open(path, 'rb+')
obj = pickle.load(pickle_fd)
print "pickled object loaded as 'obj'"
while True:
    command = raw_input("Enter command: ")
    command = command.lower().strip()
    if command in ['o', 'open']:
        path = raw_input("Path to open: ")
        pickle_fd = open(path, 'rb+')
        obj = pickle.load(pickle_fd)
    elif command in ['h', 'help']:
        print "Valid commands include:"
        print "(d)isplay to display the opened pickled object"
        print "(e)dit to edit the opened pickled object"
        print "(o)pen to open a new pickle file"
        print "(c)lose to close the opened pickled object"
        print "(q)uit to quit pickle editor"