def compile_av(self):
        time.sleep(1)

        import subprocess as sp

        save_dir = SETTINGS.settings_list['save_dir']

        try:
            vd_in = max(glob.iglob(os.path.join(TMP_DIR, '*.mp4')),
                        key=os.path.getctime)
        except Exception as e:
            dialog.ErrorMsg(repr(e))

        try:
            os.environ["File"]
            out = os.path.join(
                save_dir,
                os.environ['File'] + '.' + SETTINGS.settings_list['ext'])
        except KeyError:
            os.environ[
                "File"] = "new_output" + '.' + SETTINGS.settings_list['ext']
        finally:
            if os.environ['File'] != '':
                out = os.path.join(
                    save_dir,
                    os.environ['File'] + '.' + SETTINGS.settings_list['ext'])
            else:
                out = os.path.join(
                    save_dir,
                    'new_output' + '.' + SETTINGS.settings_list['ext'])

        if os.path.isfile(out):

            question = dialog.QuestionDialog(
                'This File exists. Are you sure you wish to overwrite it?')

            if question.clickedButton() == question.yes:
                self.ex = '%s -i %s -codec copy -y %s' % (FFMPEG_BIN, vd_in,
                                                          out)
                sp.call(self.ex, shell=True, stderr=sp.PIPE)
            else:
                pass
        else:
            self.ex = 'ffmpeg -i %s -codec copy -y %s' % (vd_in, out)
            sp.call(self.ex, shell=True, stderr=sp.PIPE)

        if ('question' in locals() and question.clickedButton()
                == question.yes) or ('question' not in locals()):
            os.remove(vd_in)
            if os.path.isfile(out):
                os.environ['LastFile'] = out
            else:
                dialog.ErrorMsg("File Not Found. Failed to save.")
        else:
            os.environ['LastFile'] = vd_in
    def record(self):
        import subprocess as sp

        try:
            self.isRunning = True
            self.pipe = sp.Popen(self.command, stderr=sp.PIPE)
        except (sp.CalledProcessError, Exception) as e:
            self.isRunning = False
            dialog.ErrorMsg(repr(e))
    def stop(self):
        try:
            self.pipe.terminate()
        except:
            e = traceback.format_exc()
            self.pipe = None
            dialog.ErrorMsg(repr(e))

        self.isRunning = False
Example #4
0
 def saveGraphic(self):
     saveFile = dialog.SaveDialog('new-save.scr', '*.scr')
     try:
         if saveFile.fname[0] != '':
             common.Save(saveFile.fname[0], self.lines)
             self.saved = True
     except:
         e = traceback.format_exc()
         dialog.ErrorMsg(e)
Example #5
0
    def saveScreen(self):

        try:
            saveFile = dialog.SaveDialog('new-save.jpg')

            if saveFile.fname[0] != '':
                screen = self.grab()
                screen.save(saveFile.fname[0], 'jpg')
        except:
            e = traceback.format_exc()
            dialog.ErrorMsg(e)
Example #6
0
    def __init__(self, file, contents):
        import struct

        self.FILE = file

        if not self.FILE.endswith('.scr'):
            self.FILE += '.scr'

        self.CONTENTS = list(bytes(str(contents), 'utf-8'))

        if not self.CONTENTS == [91, 93]:
            with open(self.FILE, "wb+") as f:
                for char in self.CONTENTS:
                    f.write(struct.pack('h', char))
                f.close()
        else:
            dialog.ErrorMsg("There is no data to save!")
Example #7
0
    def load_contents(self):
        import ast, struct
        if self.FILE.endswith('.scr'):
            with open(self.FILE, 'rb') as f:
                self.Contents = f.read()
                f.close()

            fmt = '>' + str(len(self.Contents)) + 'c'

            self.Contents = struct.unpack(fmt, self.Contents)
            for char in self.Contents:
                tmp = char.decode('utf-8')
                if tmp != '\x00':
                    self.byte_list.append(tmp)

            self.Contents = ''.join(self.byte_list)
            self.Contents = ast.literal_eval(self.Contents)
        else:
            dialog.ErrorMsg('Unrecognised File Extension.')
Example #8
0
    def openGraphic(self):

        openFile = dialog.OpenDialog()

        if openFile.filenames:
            new_file = openFile.filenames[0]
        else:
            new_file = None

        if new_file != '' and new_file is not None:
            try:
                self.clearGraphic()
                data = common.Open(new_file)

                for line in data.Contents:

                    if line['Line']['Colour'] == 2:
                        line['Line']['Colour'] = Qt.black
                    elif line['Line']['Colour'] == 12:
                        line['Line']['Colour'] = Qt.yellow
                    elif line['Line']['Colour'] == 8:
                        line['Line']['Colour'] = Qt.green
                    elif line['Line']['Colour'] == 7:
                        line['Line']['Colour'] = Qt.red
                    elif line['Line']['Colour'] == 9:
                        line['Line']['Colour'] = Qt.blue
                    elif line['Line']['Colour'] == 5:
                        line['Line']['Colour'] = Qt.gray

                    self.initTools(line['Line']['Colour'],
                                   line['Line']['Thickness'])

                    self.scene.addLine(
                        QLineF(
                            QPoint(line['Line']['Points']['begin'][0],
                                   line['Line']['Points']['begin'][1]),
                            QPoint(line['Line']['Points']['end'][0],
                                   line['Line']['Points']['end'][1])),
                        self.pen)

                    self.lines.append({
                        'Line': {
                            'Points': {
                                'begin': [
                                    line['Line']['Points']['begin'][0],
                                    line['Line']['Points']['begin'][1]
                                ],
                                'end': [
                                    line['Line']['Points']['end'][0],
                                    line['Line']['Points']['end'][1]
                                ]
                            },
                            'Thickness': line['Line']['Thickness'],
                            'Colour': line['Line']['Colour'],
                        }
                    })
                    self.tmp_lst = list()
                    self.deleted_lines = list()
                    self.redo_lst = list()
            except:
                e = traceback.format_exc()
                dialog.ErrorMsg(e)