Example #1
0
def ReportShutdownException():

    text = 'A serious error occurred while trying to exit the program. Its traceback may be shown next. It should have also been written to client.log. You may need to quit the program from task manager.'

    HydrusData.DebugPrint(text)

    HydrusData.DebugPrint(traceback.format_exc())

    wx.SafeShowMessage('shutdown error', text)
    wx.SafeShowMessage('shutdown error', traceback.format_exc())
Example #2
0
def report_fatal_error(*,
                       title,
                       message,
                       exc_info=True,
                       exit_code=1,
                       log_file=None,
                       show_gui=False):
    MESSAGE_FORMAT = "%(asctime)s %(name)s %(levelname)s: %(message)s"
    DATE_FORMAT = "%d/%m/%Y %H:%M:%S"
    logger = logging.getLogger("")
    logger.addHandler(logging.StreamHandler(sys.stderr))

    if log_file is not None:
        file_handler = logging.FileHandler(filename=log_file, mode="w")
        file_handler.setFormatter(
            logging.Formatter(MESSAGE_FORMAT, datefmt=DATE_FORMAT))
        logger.addHandler(file_handler)

    logger.debug("An error was occurred while starting the application.")
    logger.fatal(title)
    logger.fatal(message)
    if exc_info:
        logger.exception("ERROR DETAILS:\n", exc_info=True)

    if show_gui:
        try:
            import wx

            wx.SafeShowMessage(title, message)
        except:
            logger.fatal("Failed to report error graphically")
    sys.exit(exit_code)
    def OnLoad(self, event):
        dlg = wx.FileDialog(self,
                            message='Open Video File',
                            defaultDir='',
                            defaultFile='',
                            wildcard=self.wildcard,
                            style=wx.FD_OPEN)

        if dlg.ShowModal() == wx.ID_OK:
            self.video_path = dlg.GetPath()
            dlg.Destroy()
            fpath = self.video_path.split('.')
            self.write_path = fpath[0] + '_annot.txt'
            self.PROCESSING_FLAG = True
            self.videoCapture = cv2.VideoCapture(self.video_path)
            if (self.videoCapture == None):
                wx.SafeShowMessage('start', 'Open Failed')
                return
            self.TotalFrame = self.videoCapture.get(cv2.CAP_PROP_FRAME_COUNT)
            self.m_slider.SetMax(int(self.TotalFrame))
            self.fps = self.videoCapture.get(cv2.CAP_PROP_FPS)
            self.FrameTime = 1000 / self.fps
            self.m_timer1.Start(self.FrameTime)
            self.Inform_bar.SetValue('Video Loaded : ' + self.video_path)
            event.Skip()
 def OnLoad(self, event):
     self.videoCapture = cv2.VideoCapture(self.video_path)
     if (self.videoCapture == None):
         wx.SafeShowMessage('start', 'Open Failed')
         return
     self.TotalFrame = self.videoCapture.get(cv2.CAP_PROP_FRAME_COUNT)
     self.m_slider.SetMax(int(self.TotalFrame))
     self.fps = self.videoCapture.get(cv2.CAP_PROP_FPS)
     self.FrameTime = 1000 / self.fps
     self.m_timer1.Start(self.FrameTime)
     self.Inform_bar.SetValue('Video Loaded : ' + self.video_path)
     self.PROCESSING_FLAG = True
     event.Skip()
Example #5
0
def do_2to3_test():

    bad_filenames = ['python27.dll', 'lz4._version.so']

    for bad_filename in bad_filenames:

        path = os.path.join(HC.BASE_DIR, bad_filename)

        if os.path.exists(path):

            message = 'It looks like you still have some Python 2 files in your install directory! Hydrus is now Python 3 and needs a clean install. Please check the v335 release post for more information! The program will now exit!'

            wx.SafeShowMessage('Python 2/3 Error!', message)

            print(message)

            raise Exception('Client needs a clean install!')
    def Load1(self, event):
        dlg1 = wx.FileDialog(self,
                             message='Open Video File',
                             defaultDir='',
                             defaultFile='',
                             wildcard=self.wildcard,
                             style=wx.FD_OPEN)

        if dlg1.ShowModal() == wx.ID_OK:  #Do something
            self.AnnotationList = []
            self.video_path1 = dlg1.GetPath()
            dlg1.Destroy()
            fpath1 = self.video_path1.split('.')
            self.write_path = fpath1[0] + '_annot.txt'
            print(self.write_path)
            # read timestamp
            try:
                self.ts_path1 = fpath1[
                    0] + 'ts.txt'  #if the file is named as xxx_depthts or rgbts
                print(self.ts_path1)
                f = open(self.ts_path1, 'r+')
            except FileNotFoundError:
                self.ts_path1 = fpath1[
                    0][:-5] + 'skelts.txt'  #if the file is named as xxx_skelts
                f = open(self.ts_path1, 'r+')
            finally:
                for line in f.readlines():
                    self.ts1.append(float(line))
                f.close()

            self.PROCESSING_FLAG1 = True
            self.videoCapture1 = cv2.VideoCapture(self.video_path1)
            if (self.videoCapture1 == None):
                wx.SafeShowMessage('start', 'Open Failed')
                return
            self.TotalFrame1 = self.videoCapture1.get(cv2.CAP_PROP_FRAME_COUNT)
            self.fps1 = self.videoCapture1.get(cv2.CAP_PROP_FPS)
            self.FrameTime1 = 1000 / self.fps1  #In miliseconds
            self.TotalTime1 = self.TotalFrame1 * self.FrameTime1
            self.m_slider4.SetMax(int(self.TotalFrame1))
            self.m_timer1.Start(self.FrameTime1)
            self.vidtxt1.SetValue('Video Loaded : ' + self.video_path1)
            self.index = 0
            event.Skip()
    def Load2(self, event):
        dlg2 = wx.FileDialog(self,
                             message='Open Video File',
                             defaultDir='',
                             defaultFile='',
                             wildcard=self.wildcard,
                             style=wx.FD_OPEN)

        if dlg2.ShowModal() == wx.ID_OK:  #Do something
            self.video_path2 = dlg2.GetPath()
            dlg2.Destroy()
            self.PROCESSING_FLAG2 = True

            # read timestamp
            fpath2 = self.video_path2.split('.')
            try:
                self.ts_path2 = fpath2[0] + 'ts.txt'
                f = open(self.ts_path2, 'r+')
            except FileNotFoundError:
                self.ts_path2 = fpath2[0][:-5] + 'skelts.txt'
                f = open(self.ts_path2, 'r+')
            finally:
                for line in f.readlines():
                    self.ts2.append(float(line))
                f.close()

            self.videoCapture2 = cv2.VideoCapture(self.video_path2)
            if (self.videoCapture2 == None):
                wx.SafeShowMessage('start', 'Open Failed')
                return
            self.TotalFrame2 = self.videoCapture2.get(cv2.CAP_PROP_FRAME_COUNT)
            self.fps2 = self.videoCapture2.get(cv2.CAP_PROP_FPS)
            self.FrameTime2 = 1000 / self.fps2  #In seconds
            self.TotalTime2 = self.TotalFrame2 * self.FrameTime2
            self.m_slider5.SetMax(int(self.TotalFrame2))
            self.m_timer2.Start(self.FrameTime2)
            self.vidtxt2.SetValue('Video Loaded : ' + self.video_path2)
        event.Skip()
Example #8
0
    def Load(self, event):
        dlg = wx.FileDialog(self,
                            message='Open Video File',
                            defaultDir='',
                            defaultFile='',
                            wildcard=self.wildcard,
                            style=wx.FD_OPEN)

        if dlg.ShowModal() == wx.ID_OK:  #Do something

            self.AnnotationList = []
            self.video_path = dlg.GetPath()
            print(self.video_path)
            dlg.Destroy()
            fpath = self.video_path.split('.')
            self.write_path = fpath[0][:-4] + 'annoted.txt'
            print(self.write_path)

            # read timestamps for screen video
            self.ts_path = fpath[
                0][:-4] + 'screents30.txt'  #if the file is named as xxx_depthts or rgbts
            print(self.ts_path)
            f = open(self.ts_path, 'r+')
            for line in f.readlines():
                self.ts.append(float(line))
            f.close()

            #Modify audio file
            self.audio_rpath = fpath[0][:-4] + 'screen.mp3'
            self.audio = AudioSegment.from_mp3(self.audio_rpath)
            self.slow_audio = self.Speed_Change(self.audio, self.speed_change)
            self.audio_wpath = fpath[0][:-4] + 'slow.mp3'
            self.slow_audio.export(self.audio_wpath, format="mp3")
            self.sound = vlc.MediaPlayer(self.audio_wpath)

            self.PROCESSING_FLAG = True
            self.videoCapture = cv2.VideoCapture(self.video_path)
            if (self.videoCapture == None):
                wx.SafeShowMessage('start', 'Open Failed')
                return
            self.TotalFrame = self.videoCapture.get(cv2.CAP_PROP_FRAME_COUNT)
            self.fps = self.videoCapture.get(cv2.CAP_PROP_FPS)
            self.FrameTime = (1000 / self.fps)  #In miliseconds
            self.TotalTime = self.TotalFrame * self.FrameTime
            self.m_slider1.SetMax(int(self.TotalFrame))
            self.m_textCtrl1.SetValue('Video Loaded : ' + self.video_path)

            # Read timestamps for gestures
            self.ts_gest = fpath[
                0][:-4] + 'kthreelog.txt'  #file time stamps gestures
            g = open(self.ts_gest, 'r+')
            for line in g.readlines():
                self.tsg.append(float(line.split(',')[0]))
                self.gest.append(line.split(',')[19])
                self.yon.append(line.split(',')[18])
            g.close()

            #Start timer and audio
            self.m_timer1.Start(1000 / self.fps)
            self.sound.play()

        event.Skip()
Example #9
0
    if result.temp_dir is not None:

        HydrusPaths.SetEnvTempDir(result.temp_dir)

except Exception as e:

    import traceback
    import os

    error_trace = traceback.format_exc()

    print(error_trace)

    wx.SafeShowMessage(
        'critical boot error!',
        'Critical boot error occurred! Details written to crash.log!' +
        os.linesep * 2 + str(e))

    if 'db_dir' in locals() and os.path.exists(db_dir):

        dest_path = os.path.join(db_dir, 'crash.log')

        with open(dest_path, 'w', encoding='utf-8') as f:

            f.write(error_trace)

        print('Critical boot error occurred! Details written to crash.log!')

    sys.exit(1)

with HydrusLogger.HydrusLogger(db_dir, 'client') as logger:
Example #10
0
# Global Assembly Cache (GAC).
# This should be removed, eventually.
import winpaths

_windows_root = winpaths.get_windows()
_speech_assembly = glob(
    os.path.join(
        _windows_root,
        "Microsoft.NET\\assembly\\GAC_MSIL\\",
        "System.Speech\*\System.Speech.dll",
    ))

# Add CLR assembly-references here
try:
    if not _speech_assembly:
        raise FileNotFoundException
    clr.AddReference(os.path.abspath(_speech_assembly[0]))
except FileNotFoundException:
    import wx

    wx.SafeShowMessage(
        "Unable To Start",
        "Bookworm is unable to start because a key component is missing from your system.\n"
        "Bookworm requires that the .NET Framework v4.0 or a later version is present in the target system.\n"
        "Head over to the following link to download and install the .NET Framework v4.0:\n"
        "https://www.microsoft.com/en-us/download/details.aspx?id=17718",
    )
    sys.exit(1)
del _windows_root
del _speech_assembly
Example #11
0
def OnClick(event):
    wx.SafeShowMessage('Message', 'You clicked')
Example #12
0
 def OnMenuAbout(self, event):
     wx.SafeShowMessage(u'情報', 'BIG Button Pressed!')