コード例 #1
0
 def test_log_priority_value(self):
     # _log should return None if and only if priority_level argument is less than instance priority
     warning_ex = Logger(
         "_.txt", priority="warning")  # Logger.priorities["warning"] = 3
     assert warning_ex._log(1, "") is None
     assert warning_ex._log(2, "") is None
     assert warning_ex._log(3, "") is not None
     assert warning_ex._log(4, "") is not None
     assert warning_ex._log(5, "") is not None
コード例 #2
0
ファイル: camera.py プロジェクト: arbaz52/darts-python-server
 def loadSnapShot(self, ss):
     self.processedFrame = ss[0]
     self.processedFrameTime = ss[1]
     self.tk = ss[2]
     self.invalidframescount = ss[3]
     if ss[4] != self.url or ss[5] != self.lat or ss[6] != self.lng:
         Logger._log("INFO", "Physical aspects of this camera changed",
                     True)
         Logger._log("INFO", "Tracking restarted for this camera", True)
         self.tk = Tracking(1)
         return True
     return False
コード例 #3
0
ファイル: camera.py プロジェクト: arbaz52/darts-python-server
 def _setupUsingVC(self):
     try:
         Logger._log("INFO", "Opening video capture for camera " + self._id)
         self.cap = cv2.VideoCapture(self.url)
         Logger._log("SUCC", "Video Capture opened!")
     except:
         Logger._log("ERR",
                     "Couldn't open video capture for camera " + self._id)
コード例 #4
0
ファイル: camera.py プロジェクト: arbaz52/darts-python-server
 def _setupUsingStream(self):
     self._stream = None
     self.bytes = bytes()
     try:
         Logger._log("INFO", "Opening camera stream!")
         self._stream = urllib.request.urlopen(self.url)
         Logger._log("SUCC", "Camera stream opened!")
     except:
         Logger._log("WARN",
                     "Couldn't start stream - Camera stream unavailable")
コード例 #5
0
    def test_log_value(self):
        # _log's non-None return value should respect its arguments
        test_string = "hello"

        # with datetime = False, scriptname = False, we should just append "\n"
        plain_string = Logger("_.txt",
                              priority="debug",
                              datetime=False,
                              scriptname=False)
        assert plain_string._log(1, test_string) == test_string + "\n"

        # with datetime = True, scriptname = False, we should also prepend datetime followed by a spacer
        datetime = Logger("_.txt",
                          priority="debug",
                          datetime=True,
                          scriptname=False)
        assert datetime._log(
            1,
            test_string) == time.ctime() + Logger.spacer + test_string + "\n"

        # with datetime = False, scriptname = True, we should prepend scriptname followed by a spacer
        scriptname = Logger("_.txt",
                            priority="debug",
                            datetime=False,
                            scriptname=True)
        # to get full testing, you have to run pytest and run this method from the console, i suppose
        if sys.argv[0]:
            assert scriptname._log(
                1, test_string) == (os.path.basename(sys.argv[0]) +
                                    Logger.spacer + test_string + "\n")
        else:
            assert scriptname._log(
                1, test_string
            ) == "[console]" + Logger.spacer + test_string + "\n"

        # with datetime = True, scriptname = True, we should prepend datetime, spacer, scriptname, spacer
        both = Logger("_.txt",
                      priority="debug",
                      datetime=True,
                      scriptname=True)
        if sys.argv[0]:
            assert both._log(
                1, test_string) == (time.ctime() + Logger.spacer +
                                    os.path.basename(sys.argv[0]) +
                                    Logger.spacer + test_string + "\n")
        else:
            assert both._log(1, test_string) == (time.ctime() + Logger.spacer +
                                                 "[console]" + Logger.spacer +
                                                 test_string + "\n")
コード例 #6
0
ファイル: server.py プロジェクト: arbaz52/darts-python-server
 def log(self, _type, msg):
     Logger._log(_type, msg)
コード例 #7
0
ファイル: camera.py プロジェクト: arbaz52/darts-python-server
 def connect(self):
     self.invalidframescount = 0
     Logger._log("CONN",
                 "connecting to camera " + self._id + ", url: " + self.url)
     self.cap = cv2.VideoCapture(self.url)
     Logger._log("DONE", "done")
コード例 #8
0
 def log(self, _type, msg, printOnTerminal=False):
     Logger._log(_type, msg, printOnTerminal)