def test_logging(): logger = logging.getLogger() logger.info('info test') logger.error('error test') logger.warning('warning test') private_logger = logging._get_logging().getLogger("TESTLOGGER.CHILD.GRANDCHILD") formatter = logging._get_logging().Formatter(logging._formats['DEBUG']) console = logging._get_logging().StreamHandler() console.setFormatter(formatter) private_logger.setLevel(logging._get_logging().DEBUG) private_logger.addHandler(console) private_logger.critical('hello')
"""Wrapper around the publish features of stomp.py.""" import time from Queue import Queue from Ganga.Utility.logging import _get_logging logging_DEBUG = _get_logging().DEBUG BEAT_TIME = 0.3 # Seconds between publisher thread heart beats. IDLE_TIMEOUT = 30 # Maximum seconds to idle before closing connection. EXIT_TIMEOUT = 5 # Maximum seconds to clear queued messages on exit. PUBLISHER_TIMESTAMP_HEADER = '_publisher_timestamp' # The publisher timestamp header name try: import stomp stomp_listener = stomp.ConnectionListener stomp_major_version = int(stomp.__version__[0]) except (Exception, ImportError) as err: if not isinstance(err, ImportError): print("Error Importing Stomp utility!") print("err: %s" % str(err)) class stomp(object): def __init__(self): ## DUMMY CLASS pass @staticmethod def Connection(self, _server_and_port, user, password):
from Ganga.GPIDev.Adapters.IGangaFile import IGangaFile from Ganga.Utility.logging import getLogger, _get_logging from Ganga.GPIDev.Base.Proxy import isType, GPIProxyObjectFactory from Ganga.Utility.Config import getConfig import re import copy import glob import os import pickle import stat import Ganga.Utility.Config logger = getLogger() regex = re.compile('[*?\[\]]') badlogger = getLogger('oauth2client.util') badlogger.setLevel(_get_logging().ERROR) class GoogleFile(IGangaFile): """ The GoogleFile outputfile type allows for files to be directly uploaded, downloaded, removed and restored from the GoogleDrive service. It can be used as part of a job to output data directly to GoogleDrive, or standalone through the Ganga interface. example job: j=Job(application=Executable(exe=File('/home/hep/hs4011/Tests/testjob.sh'), args=[]),outputfiles=[GoogleFile('TestJob.txt')]) j.submit() ### This job will automatically upload the outputfile 'TestJob.txt' to GoogleDrive. example of standalone submission:
"""Utilities for using MSG within Ganga. """ # default stomp.py logging to CRITICAL import Ganga.Utility.Config as Config config = Config.getConfig('Logging') # test if stomp.py logging is already set if 'stomp.py' in config: pass # config['stomp.py'] else: from Ganga.Utility.logging import getLogger, _get_logging # set stomp.py logger to CRITICAL getLogger('stomp.py').setLevel(_get_logging().CRITICAL) def createPublisher(server, port, user='******', password='******', idle_timeout=None, exit_timeout=None): """Create a new publisher thread which extends GangaThread where available (i.e. on the client) or Thread otherwise (i.e. on the worker node). N.B. If GangaThread is not available then an exit handler is added, with the given timeout. @param server: The server host name. @param user: The user name. @param password: The password. @param logger: The logger instance. @param idle_timeout: Maximum seconds to idle before closing connection. Negative value indicates never close connection. @param exit_timeout: Maximum seconds to clear message queue on exit.
"""Utilities for using MSG within Ganga. """ # default stomp.py logging to CRITICAL import Ganga.Utility.Config as Config config = Config.getConfig("Logging") # test if stomp.py logging is already set if "stomp.py" in config: pass # config['stomp.py'] else: from Ganga.Utility.logging import getLogger, _get_logging # set stomp.py logger to CRITICAL getLogger("stomp.py").setLevel(_get_logging().CRITICAL) def createPublisher(server, port, user="******", password="******", idle_timeout=None, exit_timeout=None): """Create a new publisher thread which extends GangaThread where available (i.e. on the client) or Thread otherwise (i.e. on the worker node). N.B. If GangaThread is not available then an exit handler is added, with the given timeout. @param server: The server host name. @param user: The user name. @param password: The password. @param logger: The logger instance. @param idle_timeout: Maximum seconds to idle before closing connection. Negative value indicates never close connection.