Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cueadmin api updates #45

Merged
merged 4 commits into from
Dec 11, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
373 changes: 216 additions & 157 deletions cueadmin/common/common.py

Large diffs are not rendered by default.

415 changes: 227 additions & 188 deletions cueadmin/common/output.py

Large diffs are not rendered by default.

24 changes: 13 additions & 11 deletions cueadmin/common/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@


"""Utility functions for Cue3Tools"""
import logging
import sys
import time
import logging

from Manifest import Cue3

__ALL__ = ["enableDebugLogging",
"promptYesNo",
"waitOnJobName"]


def enableDebugLogging():
"""enables debug logging for cue3 and cue3 tools"""
logger = logging.getLogger("cue3")
Expand All @@ -33,24 +34,26 @@ def enableDebugLogging():
logger.addHandler(console)
logger.setLevel(logging.DEBUG)

def promptYesNo(prompt, force = False):

def promptYesNo(prompt, force=False):
"""Asks the user the supplied question and returns with a boolean to
indicate the users input.
@type option: string
@param option: The question that the user can see
@type prompt: string
@param prompt: The question that the user can see
@type force: boolean
@param force: (Optional) If true, skips the prompt and returns true
@rtype: bool
@return: The users response"""
try:
result = force or raw_input("%s [y/n] " %prompt) in ("y", "Y")
result = force or raw_input("%s [y/n] " % prompt) in ("y", "Y")
except KeyboardInterrupt:
print
raise
if not result: print "Canceled"
if not result:
print "Canceled"
return result

def waitOnJobName(jobName, maxWaitForLaunch = None):

def waitOnJobName(jobName, maxWaitForLaunch=None):
"""Waits on the given job name to enter and then leave the queue.
@type jobName: str
@param jobName: Full name of the job
Expand All @@ -67,7 +70,7 @@ def waitOnJobName(jobName, maxWaitForLaunch = None):
time.sleep(4)
while True:
try:
isPending = Cue3.isJobPending(jobName.lower())
isPending = Cue3.api.isJobPending(jobName.lower())
isLocated = isLocated or isPending

if isLocated:
Expand All @@ -79,10 +82,9 @@ def waitOnJobName(jobName, maxWaitForLaunch = None):
waited += delay
if maxWaitForLaunch and waited >= maxWaitForLaunch:
return False
except Cue3.ConnectionRefusedException, e:
except Cue3.CueException, e:
print >>sys.stderr, "Error: %s" % e
except Exception, e:
print >>sys.stderr, "Error: %s" % e

time.sleep(delay)

374 changes: 206 additions & 168 deletions cueadmin/main.py

Large diffs are not rendered by default.

Loading