当前位置: 首页>>代码示例>>Python>>正文


Python logger.error函数代码示例

本文整理汇总了Python中mydata.logs.logger.error函数的典型用法代码示例。如果您正苦于以下问题:Python error函数的具体用法?Python error怎么用?Python error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的mydata.logs.logger.error函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。