本文整理汇总了Python中mydata.logs.logger.error函数的典型用法代码示例。如果您正苦于以下问题:Python error函数的具体用法?Python error怎么用?Python error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了error函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: CheckConnectivityWorker
def CheckConnectivityWorker():
"""
Checks network connectivity in separate thread.
"""
wx.CallAfter(BeginBusyCursorIfRequired)
# pylint: disable=broad-except
try:
activeNetworkInterfaces = \
UploaderModel.GetActiveNetworkInterfaces()
except Exception, err:
logger.error(traceback.format_exc())
if type(err).__name__ == "WindowsError" and \
"The handle is invalid" in str(err):
message = "An error occurred, suggesting " \
"that you have launched MyData.exe from a " \
"Command Prompt window. Please launch it " \
"from a shortcut or from a Windows Explorer " \
"window instead.\n" \
"\n" \
"See: https://bugs.python.org/issue3905"
def ShowErrorDialog(message):
"""
Show error dialog in main thread.
"""
dlg = wx.MessageDialog(None, message, "MyData",
wx.OK | wx.ICON_ERROR)
dlg.ShowModal()
wx.CallAfter(ShowErrorDialog, message)
开发者ID:mytardis,项目名称:mydata,代码行数:29,代码来源:__init__.py
示例2: VerificationWorker
def VerificationWorker(self):
# pylint: disable=fixme
# FIXME: Should this be in verifications (not folders) controller?
"""
One worker per thread.
By default, up to 5 threads can run simultaneously
for verifying whether local data files exist on
the MyTardis server.
"""
while True:
if self.IsShuttingDown():
return
task = self.verificationsQueue.get()
if task is None:
break
# pylint: disable=bare-except
try:
task.Run()
except ValueError, err:
if str(err) == "I/O operation on closed file":
logger.info(
"Ignoring closed file exception - it is normal "
"to encounter these exceptions while canceling "
"uploads.")
self.verificationsQueue.task_done()
return
else:
logger.error(traceback.format_exc())
self.verificationsQueue.task_done()
return
except:
开发者ID:nrmay,项目名称:mydata,代码行数:31,代码来源:folders.py
示例3: Verify
def Verify(settingsModel, datafileId):
"""
Verify a datafile via the MyTardis API.
"""
myTardisUrl = settingsModel.GetMyTardisUrl()
myTardisUsername = settingsModel.GetUsername()
myTardisApiKey = settingsModel.GetApiKey()
url = myTardisUrl + "/api/v1/dataset_file/%s/verify/" % datafileId
headers = {
"Authorization": "ApiKey %s:%s" % (myTardisUsername,
myTardisApiKey),
"Content-Type": "application/json",
"Accept": "application/json"}
response = requests.get(url=url, headers=headers)
if response.status_code < 200 or response.status_code >= 300:
logger.error("Failed to verify datafile id \"%s\" "
% datafileId)
logger.error(response.text)
return False
# Returning True doesn't mean that the file has been verified.
# It just means that the MyTardis API has accepted our verification
# request without raising an error. The verification is asynchronous
# so it might not happen immediately if there is congestion in the
# Celery queue.
return True
开发者ID:mytardis,项目名称:mydata,代码行数:25,代码来源:datafile.py
示例4: GetUserByEmail
def GetUserByEmail(settingsModel, email):
myTardisUrl = settingsModel.GetMyTardisUrl()
myTardisUsername = settingsModel.GetUsername()
myTardisApiKey = settingsModel.GetApiKey()
url = myTardisUrl + "/api/v1/user/?format=json&email__iexact=" + \
urllib2.quote(email)
headers = {
"Authorization": "ApiKey %s:%s" % (myTardisUsername,
myTardisApiKey)}
try:
response = requests.get(url=url, headers=headers)
except:
raise Exception(traceback.format_exc())
if response.status_code != 200:
logger.debug(url)
message = response.text
raise Exception(message)
try:
userRecordsJson = response.json()
except:
logger.error(traceback.format_exc())
raise
numUserRecordsFound = userRecordsJson['meta']['total_count']
if numUserRecordsFound == 0:
raise DoesNotExist(
message="User with email \"%s\" was not found in MyTardis"
% email,
url=url, response=response)
else:
logger.debug("Found user record for email '" + email + "'.")
return UserModel(settingsModel=settingsModel,
userRecordJson=userRecordsJson['objects'][0])
开发者ID:nrmay,项目名称:mydata,代码行数:34,代码来源:user.py
示例5: endBusyCursorIfRequired
def endBusyCursorIfRequired():
try:
wx.EndBusyCursor()
except wx._core.PyAssertionError, e:
if "no matching wxBeginBusyCursor()" not in str(e):
logger.error(str(e))
raise
开发者ID:monash-merc,项目名称:mydata,代码行数:7,代码来源:MyData.py
示例6: Notify
def Notify(message, subtitle=None, title="MyData"):
"""
Post notification.
"""
if sys.platform.startswith("win"):
wx.GetApp().taskBarIcon.ShowBalloon(title, message)
return
path = "resources/macosx/MyData Notifications.app/Contents/MacOS"
executable = "MyData Notifications"
args = ["-message", message, "-title", title, "-sound", "Purr"]
if subtitle:
args = args + ["-subtitle", subtitle]
if hasattr(sys, "frozen"):
args = args + ["-activate", "org.mytardis.MyData"]
else:
args = args + ["-activate", "org.python.python"]
if hasattr(sys, "frozen"):
path = "../MacOS"
else:
path = "resources/macosx/MyData Notifications.app/Contents/MacOS"
proc = subprocess.Popen([os.path.join(path, executable)] + args,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
stdout, _ = proc.communicate()
if proc.returncode != 0:
logger.error(stdout)
开发者ID:nrmay,项目名称:mydata,代码行数:26,代码来源:notification.py
示例7: ValidateSettings
def ValidateSettings():
"""
Validate settings.
"""
logger.debug("Starting run() method for thread %s" % threading.current_thread().name)
# pylint: disable=bare-except
try:
wx.CallAfter(wx.BeginBusyCursor)
# pylint: disable=broad-except
try:
activeNetworkInterfaces = UploaderModel.GetActiveNetworkInterfaces()
except Exception, err:
logger.error(traceback.format_exc())
if type(err).__name__ == "WindowsError" and "The handle is invalid" in str(err):
message = (
"An error occurred, suggesting "
"that you have launched MyData.exe from a "
"Command Prompt window. Please launch it "
"from a shortcut or from a Windows Explorer "
"window instead.\n"
"\n"
"See: https://bugs.python.org/issue3905"
)
def ShowErrorDialog(message):
"""
Needs to run in the main thread.
"""
dlg = wx.MessageDialog(None, message, "MyData", wx.OK | wx.ICON_ERROR)
dlg.ShowModal()
wx.CallAfter(ShowErrorDialog, message)
if len(activeNetworkInterfaces) == 0:
message = (
"No active network interfaces."
"\n\n"
"Please ensure that you have an active "
"network interface (e.g. Ethernet or WiFi)."
)
def ShowDialog():
"""
Needs to run in the main thread.
"""
dlg = wx.MessageDialog(None, message, "MyData", wx.OK | wx.ICON_ERROR)
dlg.ShowModal()
wx.CallAfter(EndBusyCursorIfRequired)
self.frame.SetStatusMessage("")
self.frame.SetConnected(self.settingsModel.GetMyTardisUrl(), False)
wx.CallAfter(ShowDialog)
return
self.settingsValidation = self.settingsModel.Validate()
event = mde.MyDataEvent(
mde.EVT_SETTINGS_VALIDATION_FOR_REFRESH_COMPLETE, needToValidateSettings=False
)
wx.PostEvent(self.frame, event)
wx.CallAfter(EndBusyCursorIfRequired)
开发者ID:nrmay,项目名称:mydata,代码行数:59,代码来源:MyData.py
示例8: GetDataFileModifiedTime
def GetDataFileModifiedTime(self, dataFileIndex):
absoluteFilePath = self.GetDataFilePath(dataFileIndex)
try:
modifiedTimeIsoString = datetime.fromtimestamp(
os.stat(absoluteFilePath).st_mtime).isoformat()
return modifiedTimeIsoString
except: # pylint: disable=bare-except
logger.error(traceback.format_exc())
return None
开发者ID:mytardis,项目名称:mydata,代码行数:9,代码来源:folder.py
示例9: GetDataFileCreatedTime
def GetDataFileCreatedTime(self, dataFileIndex):
absoluteFilePath = self.GetDataFilePath(dataFileIndex)
try:
createdTimeIsoString = datetime.fromtimestamp(
os.stat(absoluteFilePath).st_ctime).isoformat()
return createdTimeIsoString
except:
logger.error(traceback.format_exc())
return None
开发者ID:monash-merc,项目名称:mydata,代码行数:9,代码来源:folder.py
示例10: EndBusyCursorIfRequired
def EndBusyCursorIfRequired():
# pylint: disable=no-member
# Otherwise pylint complains about PyAssertionError.
# pylint: disable=protected-access
try:
wx.EndBusyCursor()
except wx._core.PyAssertionError, err:
if "no matching wxBeginBusyCursor()" \
not in str(err):
logger.error(str(err))
raise
开发者ID:nrmay,项目名称:mydata,代码行数:11,代码来源:uploads.py
示例11: Delete
def Delete(self):
# pylint: disable=bare-except
try:
os.unlink(self.privateKeyFilePath)
if self.publicKeyFilePath is not None:
os.unlink(self.publicKeyFilePath)
except:
logger.error(traceback.format_exc())
return False
return True
开发者ID:mytardis,项目名称:mydata,代码行数:11,代码来源:openssh.py
示例12: InitForUploads
def InitForUploads(self):
fc = self # pylint: disable=invalid-name
app = wx.GetApp()
if hasattr(app, "TestRunRunning"):
fc.testRun = app.TestRunRunning()
else:
fc.testRun = False
fc.SetStarted()
settingsModel = fc.settingsModel
fc.SetCanceled(False)
fc.SetFailed(False)
fc.SetCompleted(False)
fc.verificationsModel.DeleteAllRows()
fc.uploadsModel.DeleteAllRows()
fc.uploadsModel.SetStartTime(datetime.datetime.now())
fc.verifyDatafileRunnable = {}
fc.verificationsQueue = Queue.Queue()
fc.numVerificationWorkerThreads = \
settingsModel.GetMaxVerificationThreads()
fc.verificationWorkerThreads = []
for i in range(fc.numVerificationWorkerThreads):
thread = threading.Thread(name="VerificationWorkerThread-%d" % (i + 1),
target=fc.VerificationWorker)
fc.verificationWorkerThreads.append(thread)
thread.start()
fc.uploadDatafileRunnable = {}
fc.uploadsQueue = Queue.Queue()
fc.numUploadWorkerThreads = settingsModel.GetMaxUploadThreads()
fc.uploadMethod = UploadMethod.HTTP_POST
fc.getOrCreateExpThreadingLock = threading.Lock()
if sys.platform.startswith("linux"):
RestartErrandBoy()
# pylint: disable=broad-except
try:
settingsModel.GetUploaderModel().RequestStagingAccess()
uploadToStagingRequest = settingsModel\
.GetUploadToStagingRequest()
except Exception, err:
# MyData app could be missing from MyTardis server.
logger.error(traceback.format_exc())
wx.PostEvent(
self.notifyWindow,
self.showMessageDialogEvent(
title="MyData",
message=str(err),
icon=wx.ICON_ERROR))
return
开发者ID:mytardis,项目名称:mydata,代码行数:50,代码来源:folders.py
示例13: EndBusyCursorIfRequired
def EndBusyCursorIfRequired():
"""
The built in wx.EndBusyCursor raises an ugly exception if the
busy cursor has already been stopped.
"""
# pylint: disable=no-member
# Otherwise pylint complains about PyAssertionError.
# pylint: disable=protected-access
try:
wx.EndBusyCursor()
except wx._core.PyAssertionError, err:
if "no matching wxBeginBusyCursor()" not in str(err):
logger.error(str(err))
raise
开发者ID:nrmay,项目名称:mydata,代码行数:14,代码来源:MyData.py
示例14: Run
def Run(self):
"""
This method provides the functionality of
the verification workers. Data files found locally are
looked up on the MyTardis server, and are classified according
to whether they are found on the server, whether they are
verified, and if not, whether they have been completely or
partially uploaded.
"""
dataFilePath = self.folderModel.GetDataFilePath(self.dataFileIndex)
dataFileDirectory = \
self.folderModel.GetDataFileDirectory(self.dataFileIndex)
dataFileName = os.path.basename(dataFilePath)
fc = self.foldersController # pylint: disable=invalid-name
if not hasattr(fc, "verificationsThreadingLock"):
fc.verificationsThreadingLock = threading.Lock()
fc.verificationsThreadingLock.acquire()
verificationDataViewId = self.verificationsModel.GetMaxDataViewId() + 1
self.verificationModel = \
VerificationModel(dataViewId=verificationDataViewId,
folderModel=self.folderModel,
dataFileIndex=self.dataFileIndex)
self.verificationsModel.AddRow(self.verificationModel)
fc.verificationsThreadingLock.release()
self.verificationModel.SetMessage("Looking for matching file on "
"MyTardis server...")
self.verificationModel.SetStatus(VerificationStatus.IN_PROGRESS)
self.verificationsModel.MessageUpdated(self.verificationModel)
try:
dataset = self.folderModel.GetDatasetModel()
if not dataset: # test runs don't create required datasets
raise DoesNotExist("Dataset doesn't exist.")
existingDatafile = DataFileModel.GetDataFile(
settingsModel=self.settingsModel,
dataset=dataset,
filename=dataFileName,
directory=dataFileDirectory)
self.verificationModel.SetMessage("Found datafile on "
"MyTardis server.")
self.verificationModel.SetStatus(VerificationStatus.FOUND_VERIFIED)
self.verificationsModel.MessageUpdated(self.verificationModel)
self.HandleExistingDatafile(existingDatafile)
except DoesNotExist:
self.HandleNonExistentDataFile()
except: # pylint: disable=bare-except
logger.error(traceback.format_exc())
开发者ID:mytardis,项目名称:mydata,代码行数:47,代码来源:verifications.py
示例15: OnMyTardis
def OnMyTardis(self, event):
try:
import webbrowser
items = self.foldersView.GetDataViewControl().GetSelections()
rows = [self.foldersModel.GetRow(item) for item in items]
if len(rows) == 1:
folderRecord = self.foldersModel.GetFolderRecord(rows[0])
if folderRecord.GetDatasetModel() is not None:
webbrowser\
.open(self.settingsModel.GetMyTardisUrl() + "/" +
folderRecord.GetDatasetModel().GetViewUri())
else:
webbrowser.open(self.settingsModel.GetMyTardisUrl())
else:
webbrowser.open(self.settingsModel.GetMyTardisUrl())
except:
logger.error(traceback.format_exc())
开发者ID:monash-merc,项目名称:mydata,代码行数:17,代码来源:MyData.py
示例16: RequestUploadToStagingApproval
def RequestUploadToStagingApproval(self):
"""
Used to request the ability to upload via SCP
to a staging area, and then register in MyTardis.
"""
try:
keyPair = self.settingsModel.GetSshKeyPair()
if not keyPair:
keyPair = OpenSSH.FindKeyPair("MyData")
except PrivateKeyDoesNotExist:
keyPair = OpenSSH.NewKeyPair("MyData")
self.settingsModel.SetSshKeyPair(keyPair)
myTardisUrl = self.settingsModel.GetMyTardisUrl()
myTardisUsername = self.settingsModel.GetUsername()
myTardisApiKey = self.settingsModel.GetApiKey()
url = myTardisUrl + "/api/v1/mydata_uploaderregistrationrequest/"
headers = {
"Authorization": "ApiKey %s:%s" % (myTardisUsername,
myTardisApiKey),
"Content-Type": "application/json",
"Accept": "application/json"}
uploaderRegistrationRequestJson = \
{"uploader": self.responseJson['resource_uri'],
"name": self.name,
"requester_name": self.contactName,
"requester_email": self.contactEmail,
"requester_public_key": keyPair.GetPublicKey(),
"requester_key_fingerprint": keyPair.GetFingerprint()}
data = json.dumps(uploaderRegistrationRequestJson)
response = requests.post(headers=headers, url=url, data=data)
if response.status_code >= 200 and response.status_code < 300:
responseJson = response.json()
response.close()
return UploaderRegistrationRequest(
settingsModel=self.settingsModel,
uploaderRegRequestJson=responseJson)
else:
if response.status_code == 404:
response.close()
raise DoesNotExist("HTTP 404 (Not Found) received for: " + url)
logger.error("Status code = " + str(response.status_code))
logger.error("URL = " + url)
message = response.text
response.close()
raise Exception(message)
开发者ID:mytardis,项目名称:mydata,代码行数:45,代码来源:uploader.py
示例17: UploadUploaderInfo
def UploadUploaderInfo(self):
""" Uploads info about the instrument PC to MyTardis via HTTP POST """
myTardisUrl = self.settingsModel.GetMyTardisUrl()
myTardisDefaultUsername = self.settingsModel.GetUsername()
myTardisDefaultUserApiKey = self.settingsModel.GetApiKey()
url = myTardisUrl + "/api/v1/mydata_uploader/?format=json" + \
"&uuid=" + urllib.quote(self.uuid)
headers = {"Authorization": "ApiKey " + myTardisDefaultUsername + ":" +
myTardisDefaultUserApiKey,
"Content-Type": "application/json",
"Accept": "application/json"}
try:
response = requests.get(headers=headers, url=url)
except Exception, e:
logger.error(str(e))
raise
开发者ID:monash-merc,项目名称:mydata,代码行数:19,代码来源:uploader.py
示例18: __init__
def __init__(self, settingsModel=None, dataViewId=None,
username=None, name=None,
email=None, userRecordJson=None,
userNotFoundInMyTardis=False):
# pylint: disable=too-many-arguments
self.settingsModel = settingsModel
self.userId = None
self.dataViewId = dataViewId
self.username = username
self.name = name
self.email = email
self.groups = []
self.userRecordJson = userRecordJson
self.userNotFoundInMyTardis = userNotFoundInMyTardis
if userRecordJson is not None:
self.userId = userRecordJson['id']
if username is None:
self.username = userRecordJson['username']
if name is None:
self.name = userRecordJson['first_name'] + " " + \
userRecordJson['last_name']
if email is None:
self.email = userRecordJson['email']
try:
for group in userRecordJson['groups']:
self.groups.append(GroupModel(settingsModel=settingsModel,
groupJson=group))
except KeyError:
# 'groups' should be available in the user record's JSON
# if using https://github.com/monash-merc/mytardis/tree/mydata
message = "Incompatible MyTardis version" \
"\n\n" \
"You appear to be connecting to a MyTardis server whose " \
"MyTardis version doesn't provide some of the " \
"functionality required by MyData." \
"\n\n" \
"Please check that you are using the correct MyTardis " \
"URL and ask your MyTardis administrator to check " \
"that an appropriate version of MyTardis is installed."
logger.error(traceback.format_exc())
logger.error(message)
raise IncompatibleMyTardisVersion(message)
开发者ID:nrmay,项目名称:mydata,代码行数:43,代码来源:user.py
示例19: StartDataUploads
def StartDataUploads(self):
# pylint: disable=too-many-return-statements
# pylint: disable=too-many-branches
# pylint: disable=too-many-statements
fc = self # pylint: disable=invalid-name
fc.SetStarted()
settingsModel = fc.settingsModel
fc.canceled.clear()
fc.verificationsModel.DeleteAllRows()
fc.uploadsModel.DeleteAllRows()
fc.verifyDatafileRunnable = {}
fc.verificationsQueue = Queue.Queue()
# For now, the max number of verification threads is set to be the
# same as the max number of upload threads.
fc.numVerificationWorkerThreads = settingsModel.GetMaxUploadThreads()
fc.verificationWorkerThreads = []
for i in range(fc.numVerificationWorkerThreads):
thread = threading.Thread(name="VerificationWorkerThread-%d" % (i + 1),
target=fc.VerificationWorker)
fc.verificationWorkerThreads.append(thread)
thread.start()
fc.uploadDatafileRunnable = {}
fc.uploadsQueue = Queue.Queue()
fc.numUploadWorkerThreads = settingsModel.GetMaxUploadThreads()
fc.uploadMethod = UploadMethod.HTTP_POST
# pylint: disable=broad-except
try:
settingsModel.GetUploaderModel().RequestStagingAccess()
uploadToStagingRequest = settingsModel\
.GetUploadToStagingRequest()
except Exception, err:
# MyData app could be missing from MyTardis server.
logger.error(traceback.format_exc())
wx.PostEvent(
self.notifyWindow,
self.showMessageDialogEvent(
title="MyData",
message=str(err),
icon=wx.ICON_ERROR))
return
开发者ID:nrmay,项目名称:mydata,代码行数:42,代码来源:folders.py
示例20: ShowDialog
def ShowDialog(message):
"""
Show error dialog in main thread.
"""
logger.error(message)
# pylint: disable=no-member
# Otherwise pylint complains about PyAssertionError.
# pylint: disable=protected-access
try:
wx.EndBusyCursor()
if wx.version().startswith("3.0.3.dev"):
arrowCursor = wx.Cursor(wx.CURSOR_ARROW)
else:
arrowCursor = wx.StockCursor(wx.CURSOR_ARROW)
event.settingsDialog.dialogPanel.SetCursor(arrowCursor)
except wx._core.PyAssertionError, err:
if "no matching wxBeginBusyCursor()" \
not in str(err):
logger.error(str(err))
raise
开发者ID:mytardis,项目名称:mydata,代码行数:20,代码来源:__init__.py
注:本文中的mydata.logs.logger.error函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论