Exemple #1
0
	def __init__(self, cert=None, url=None, default_headers=None,
			process_result=None, process_data=None, session=None):
		self._log = logging.getLogger('webservice')
		(self._cert, self._url, self._headers, self._session) = (cert, url, default_headers, session)
		self._process_result = process_result or identity
		self._process_data = process_data or resolve_fun('urllib.parse:urlencode', 'urllib:urlencode')
		if not session:
			try:
				self._session = RestSession.create_instance('RequestsSession')
				# pulling in incompatible dependencies can cause many different types of exceptions
			except Exception:
				clear_current_exception()
				self._session = RestSession.create_instance('Urllib2Session')
Exemple #2
0
class DBS3MigrationQueue(resolve_fun('collections:deque', '<builtin>:list')):
	_unique_queued_tasks = set()

	def __init__(self, tasks=None, maxlen=None):
		super(DBS3MigrationQueue, self).__init__(iterable=tasks or [], maxlen=maxlen)

	def add_migration_task(self, migration_task):
		if migration_task not in self._unique_queued_tasks:
			self._unique_queued_tasks.add(migration_task)
			self.append(migration_task)
		else:
			raise AlreadyQueued('%s is already queued!' % migration_task)

	def read_from_disk(filename):
		return with_file(SafeFile(filename), pickle.load)
	read_from_disk = staticmethod(read_from_disk)

	def save_to_disk(self, filename):
		with_file(SafeFile(filename, 'w'), partial(pickle.dump, self))
Exemple #3
0
def _main():
    parser = ScriptOptions()
    parser.add_text(None,
                    None,
                    'url',
                    default='http://pccmsdqm04.cern.ch/runregistry/xmlrpc',
                    help='URL to runregistry [Default:%s]')
    parser.add_text(
        None,
        None,
        'run',
        default='Collisions10',
        help=
        'Specify run era that will be queried for the lumi json file [Default:%s]'
    )
    options = parser.script_parse()
    server_proxy_cls = resolve_fun('xmlrpc.client:ServerProxy',
                                   'xmlrpclib:ServerProxy')
    server = server_proxy_cls(options.opts.url).DataExporter
    data = server.export('RUNLUMISECTION', 'GLOBAL', 'json',
                         {'groupName': options.opts.run})
    logging.getLogger('script').info(json.dumps(data))
try:
	from grid_control_gui.ansi import ANSI
except Exception:
	clear_current_exception()
	ANSI = None  # pylint:disable=invalid-name
try:
	from grid_control_gui.report_bar import ProgressBarActivity
except Exception:
	clear_current_exception()
	ProgressBarActivity = ProgressActivity  # pylint:disable=invalid-name

log = logging.getLogger('se_output_download')  # pylint:disable=invalid-name
logging.getLogger('logging.process').disabled = True

get_thread_state = resolve_fun('threading:Thread.is_alive', 'threading:Thread.isAlive')  # pylint:disable=invalid-name

JobDownloadStatus = make_enum(['JOB_OK', 'JOB_ALREADY', 'JOB_NO_OUTPUT',  # pylint:disable=invalid-name
	'JOB_PROCESSING', 'JOB_FAILED', 'JOB_RETRY', 'JOB_INCOMPLETE'])
FileDownloadStatus = make_enum(['FILE_OK', 'FILE_EXISTS', 'FILE_TIMEOUT',  # pylint:disable=invalid-name
	'FILE_SE_BLACKLIST', 'FILE_HASH_FAILED', 'FILE_TRANSFER_FAILED', 'FILE_MKDIR_FAILED'])


def accepted_se(opts, fi):
	return any(imap(fi[FileInfo.Path].__contains__, opts.select_se)) or not opts.select_se


def check_token(token):
	if time.time() - check_token.last_check > 10:
		check_token.last_check = time.time()
		if not token.can_submit(20 * 60, True):
Exemple #5
0
def resolve_sfun(*args):
    return staticmethod(resolve_fun(*args))
def resolve_sfun(*args):
	return staticmethod(resolve_fun(*args))
try:
    from grid_control_gui.ansi import ANSI
except Exception:
    clear_current_exception()
    ANSI = None  # pylint:disable=invalid-name
try:
    from grid_control_gui.report_bar import ProgressBarActivity
except Exception:
    clear_current_exception()
    ProgressBarActivity = ProgressActivity  # pylint:disable=invalid-name

log = logging.getLogger('se_output_download')  # pylint:disable=invalid-name
logging.getLogger('logging.process').disabled = True

get_thread_state = resolve_fun('threading:Thread.is_alive',
                               'threading:Thread.isAlive')  # pylint:disable=invalid-name

JobDownloadStatus = make_enum([
    'JOB_OK',
    'JOB_ALREADY',
    'JOB_NO_OUTPUT',  # pylint:disable=invalid-name
    'JOB_PROCESSING',
    'JOB_FAILED',
    'JOB_RETRY',
    'JOB_INCOMPLETE'
])
FileDownloadStatus = make_enum([
    'FILE_OK',
    'FILE_EXISTS',
    'FILE_TIMEOUT',  # pylint:disable=invalid-name
    'FILE_SE_BLACKLIST',