Exemplo n.º 1
0
    def Start(self):
        self.InitI18N()
        self.InitGLib()

        DestructionManager()

        from photofilmstrip.lib.jobimpl.JobManager import JobManager
        JobManager().Init(workerCount=2)
        JobManager().Init("render")

        try:
            return self._OnStart()
        finally:
            DestructionManager().Destroy()
Exemplo n.º 2
0
 def __init__(self, win=None):
     self.__id = wx.NewId()
     if win is None:
         win = self
     assert isinstance(win, wx.EvtHandler)
     self.__win = win
     JobManager().AddVisual(self)
Exemplo n.º 3
0
    def OnRenderFilmstrip(self, event):
        self.PrepareRendering()

        project = self.__project
        dlg = DlgRender(self, project.GetAspect())
        try:
            if dlg.ShowModal() != wx.ID_OK:
                return

            profile = dlg.GetProfile()
            draftMode = dlg.GetDraftMode()
            rendererClass = dlg.GetRendererClass()
        finally:
            dlg.Destroy()

        ar = ActionRender(project, profile, rendererClass, draftMode)
        try:
            ar.Execute()
            renderJob = ar.GetRenderJob()
            JobManager().EnqueueContext(renderJob)
        except RenderException as exc:
            dlg = wx.MessageDialog(self, exc.GetMessage(), _(u"Error"),
                                   wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
Exemplo n.º 4
0
    def OnInit(self):
        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        self.svcClient = subprocess.Popen([self.svcClientPath],
                                          stdin=subprocess.PIPE,
                                          startupinfo=startupinfo)

        JobManager().AddVisual(self)
Exemplo n.º 5
0
 def OnClose(self, event):
     while self.notebook.GetPageCount() > 1:
         idx = 1
         self.notebook.SetSelection(idx)
         if self.ClosePage(idx):
             self.notebook.DeletePage(idx)
         else:
             return
     JobManager().RemoveVisual(self)
     self.frmJobManager.Destroy()
     event.Skip()
Exemplo n.º 6
0
    def Load(self, importPath=None):
        wxvJob = VisualJob(_("Loading project %s") % self._filename,
                           self.__Load, args=(importPath,))
        wxvJob.SetAltPath = self.SetAltPath
        dlg = DlgJobVisual(self.__wxParent, wxvJob)
        dlg.Bind(EVT_JOB_RESULT, self.__OnJobDone)

        wxvJob.AddVisualJobHandler(dlg)

        self.__wxvJob = wxvJob
        JobManager().EnqueueContext(wxvJob)
        try:
            return self.__WaitUntilJobDone()
        finally:
            dlg.Destroy()
Exemplo n.º 7
0
    def Save(self, includePics=False):
        wxvJob = VisualJob(_("Saving project %s") % self._filename,
                           self.__Save, args=(includePics,),
                           maxProgress=len(self._project.GetPictures()))

        dlg = DlgJobVisual(self.__wxParent, wxvJob)
        dlg.Bind(EVT_JOB_RESULT, self.__OnJobDone)

        wxvJob.AddVisualJobHandler(dlg)

        self.__wxvJob = wxvJob
        JobManager().EnqueueContext(wxvJob)
        try:
            return self.__WaitUntilJobDone()
        finally:
            dlg.Destroy()
Exemplo n.º 8
0
    def _OnStart(self, outpath, profile=None, gstElements=None):
        self._UpdateProject()
        vj = StoryEngine(self.__story.GetMedias(), outpath, profile,
                         gstElements)

        if outpath is None:
            # do a preview
            label = "Preview"
            groupId = "general"
        else:
            label = _("Generate video %s") % outpath
            groupId = "render"

        wxvJob = VisualJob(label, vj.Execute, maxProgress=100, groupId=groupId)
        if outpath:
            wxvJob.GetOutputFile = lambda: outpath
        JobManager().EnqueueContext(wxvJob)
Exemplo n.º 9
0
    def __init__(self, parent, pnlJobClass=PnlJobVisual):
        self._init_ctrls(parent)
        WxVisualJobManager.__init__(self)
        self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnSelectItem)
        self.pnlJobs.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)

        self.pnlJobs.SetupScrolling(scroll_x=False)

        self.parentFrame = None
        if isinstance(parent, wx.Frame):
            self.parentFrame = parent

        self._selected = None

        self.pnlJobVisuals = []
        self.pnlJobClass = pnlJobClass

        self.Bind(EVT_REGISTER_JOB, self.OnRegisterJob)

        JobManager().AddVisual(self)
Exemplo n.º 10
0
def main(showHelp=False):
    parser = OptionParser(prog="%s-cli" % Constants.APP_NAME.lower(),
                          version="%%prog %s" % Constants.APP_VERSION_SUFFIX)

    profiles = GetOutputProfiles() + GetMPEGProfiles()
    profStr = ", ".join(
        ["%d=%s" % (idx, prof.GetName()) for idx, prof in enumerate(profiles)])

    formatStr = ", ".join(
        ["%d=%s" % (idx, rdr.GetName()) for idx, rdr in enumerate(RENDERERS)])

    parser.add_option("-p", "--project", help=_("specifies the project file"))
    parser.add_option(
        "-o",
        "--outputpath",
        help=_("The path where to save the output files. Use - for stdout."),
        metavar="PATH")
    parser.add_option("-t",
                      "--profile",
                      help=profStr + " [default: %default]",
                      default=0,
                      type="int")
    parser.add_option(
        "-n",
        "--videonorm",
        help=_("Option videonorm is deprecated, use an appropriate profile!"))
    parser.add_option("-f",
                      "--format",
                      help=formatStr + " [default: %default]",
                      default=4,
                      type="int")
    parser.add_option(
        "-a",
        "--draft",
        action="store_true",
        default=False,
        help="%s - %s" %
        (_("enable draft mode"),
         _("Activate this option to generate a preview of your PhotoFilmStrip. The rendering process will speed up dramatically, but results in lower quality."
           )))
    parser.add_option("-d",
                      "--debug",
                      action="store_true",
                      default=False,
                      help="enable debug logging")

    if showHelp:
        parser.print_help()
        return 0

    options = parser.parse_args()[0]

    if options.project:
        options.project = os.path.abspath(options.project)
        if not os.path.isfile(options.project):
            logging.error(_("project file does not exist: %s"),
                          options.project)
            return 1
    else:
        parser.print_help()
        logging.error(_("no project file specified!"))
        return 2

    if options.videonorm:
        parser.print_help()
        logging.error(
            _("Option videonorm is deprecated, use an appropriate profile!"))
        return 4

    if options.format not in range(len(RENDERERS)):
        parser.print_help()
        logging.error(_("invalid format specified: %s"), options.format)
        return 5
    rendererClass = RENDERERS[options.format]

    if options.profile >= len(profiles):
        parser.print_help()
        logging.error(_("invalid profile specified: %s"), options.profile)
        return 3
    profile = profiles[options.profile]

    prjFile = ProjectFile(filename=options.project)
    if not prjFile.Load():
        logging.error(_("cannot load project"))
        return 6

    if options.outputpath:
        if options.outputpath == "-":
            outpath = "-"
            rendererClass = StreamRenderer
        else:
            outpath = os.path.abspath(options.outputpath)
            if not os.path.exists(outpath):
                try:
                    os.makedirs(outpath)
                except Exception as err:
                    logging.error(_("cannot create output path: %s"), err)
                    return 7
    else:
        outpath = None

    project = prjFile.GetProject()
    ar = ActionRender(project, profile, rendererClass, False, outpath)

    audioFile = project.GetAudioFile()
    if not CheckFile(audioFile):
        logging.error(_("Audio file '%s' does not exist!"), audioFile)
        return 8

    if rendererClass is StreamRenderer:
        cliGui = DummyGui()
    else:
        cliGui = CliGui()

    cliGui.Info(options.project, rendererClass, profile)

    ar.Execute()
    renderJob = ar.GetRenderJob()
    renderJob.AddVisualJobHandler(cliGui)

    JobManager().EnqueueContext(renderJob)

    try:
        while not renderJob.IsDone():
            time.sleep(0.1)
    except KeyboardInterrupt:
        renderJob.Abort()
        cliGui.Write("\n" + _("...aborted!"))
        return 10

    resultObj = renderJob.GetResultObject()
    result = resultObj.GetResult()
    if result:
        cliGui.Write(_("all done"))
Exemplo n.º 11
0
 def __init__(self):
     JobManager().AddVisual(self)
     self.notifications = {}
     self.notificationKey = 0
Exemplo n.º 12
0
    def __init__(self):
        wx.Frame.__init__(self, None, -1, name=u'FrmMain',
              pos=wx.Point(-1, -1), size=wx.Size(-1, -1),
              style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)
        WxVisualJobManager.__init__(self)
        self.SetTitle(Constants.APP_NAME)

        iconBundle = wx.IconBundle()
        iconBundle.AddIcon(wx.ArtProvider.GetIcon("PFS_ICON_16", wx.ART_OTHER))
        iconBundle.AddIcon(wx.ArtProvider.GetIcon("PFS_ICON_24", wx.ART_OTHER))
        iconBundle.AddIcon(wx.ArtProvider.GetIcon("PFS_ICON_32", wx.ART_OTHER))
        iconBundle.AddIcon(wx.ArtProvider.GetIcon("PFS_ICON_48", wx.ART_OTHER))
        iconBundle.AddIcon(wx.ArtProvider.GetIcon("PFS_ICON_64", wx.ART_OTHER))
        iconBundle.AddIcon(wx.ArtProvider.GetIcon("PFS_ICON_128", wx.ART_OTHER))
        self.SetIcons(iconBundle)

        self.statusBar = wx.StatusBar(self)
        self.statusBar.SetFieldsCount(4)
        self.statusBar.Bind(wx.EVT_LEFT_DOWN, self.OnStatusBarLeftDown)
        self.SetStatusBar(self.statusBar)

        self.menuBar = wx.MenuBar()
        self.SetMenuBar(self.menuBar)

        self.toolBar = wx.ToolBar(self)
        self.SetToolBar(self.toolBar)

        self._actionMgr = ActionManager(self, self.menuBar, self.toolBar)

        self.notebook = wx.aui.AuiNotebook(self, -1, style=wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB)
        self.notebook.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
        self.notebook.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnPageClose)

        self.pnlWelcome = PnlWelcome(self.notebook, self)
        self.pnlWelcome.SetDropTarget(ProjectDropTarget(self))

        self.notebook.AddPage(self.pnlWelcome, _(u"Welcome"), True)

        self.frmJobManager = wx.Frame(self, -1, _(u"Job queue"),
                                      size=wx.Size(600, 400),
                                      style=wx.DEFAULT_FRAME_STYLE | wx.STAY_ON_TOP)
        self.frmJobManager.SetIcon(wx.ArtProvider.GetIcon("PFS_JOB_QUEUE_16", wx.ART_OTHER))
        self.frmJobManager.Bind(wx.EVT_CLOSE, self.OnCloseFrameJobManager)
        PnlJobManager(self.frmJobManager, pnlJobClass=PnlRenderJobVisual)

        self.Bind(wx.EVT_CLOSE, self.OnClose)

        self.Bind(wx.EVT_MENU, self.OnSlideshow, id=ActionManager.ID_SLIDESHOW)
        self.Bind(wx.EVT_MENU, self.OnTimelapse, id=ActionManager.ID_TIMELAPSE)
        self.Bind(wx.EVT_MENU, self.OnStory, id=ActionManager.ID_STORY)
        self.Bind(wx.EVT_MENU, self.OnProjectLoad, id=wx.ID_OPEN)
        self.Bind(wx.EVT_MENU, self.OnProjectSave, id=wx.ID_SAVE)
        self.Bind(wx.EVT_MENU, self.OnProjectSaveAs, id=wx.ID_SAVEAS)
        self.Bind(wx.EVT_MENU, self.OnProjectClose,
                  id=ActionManager.ID_PROJECT_CLOSE)
        self.Bind(wx.EVT_MENU, self.OnExit, id=wx.ID_EXIT)

        self.Bind(wx.EVT_MENU, self.OnAbout, id=wx.ID_ABOUT)
        self.Bind(wx.EVT_MENU, self.OnHelpIndex, id=wx.ID_HELP)
        for wxId in ActionManager.LANG_MAP.keys():
            self.Bind(wx.EVT_MENU, self.OnChangeLanguage, id=wxId)

        self.Bind(wx.EVT_MENU, self.OnShowFrameJobManager,
                  id=ActionManager.ID_JOB_QUEUE)

        self.Bind(wx.EVT_UPDATE_UI, self.OnCheckProjectChanged, id=wx.ID_SAVE)
        self.Bind(wx.EVT_UPDATE_UI, self.OnCheckProjectActive, id=wx.ID_SAVEAS)
        self.Bind(wx.EVT_UPDATE_UI, self.OnCheckProjectActive,
                  id=ActionManager.ID_PROJECT_CLOSE)

        self.Bind(wx.EVT_MENU, self.OnHelpContent, id=wx.ID_HELP_CONTENTS)
        self.Bind(wx.EVT_MENU, self.OnPageNext, id=ID_PAGE_DOWN)
        self.Bind(wx.EVT_MENU, self.OnPagePrev, id=ID_PAGE_UP)

        self.SetInitialSize((720, 680))

        at = wx.AcceleratorTable([(wx.ACCEL_NORMAL, wx.WXK_F1, wx.ID_HELP_CONTENTS),
                                  (wx.ACCEL_CTRL, wx.WXK_PAGEDOWN, ID_PAGE_DOWN),
                                  (wx.ACCEL_CTRL, wx.WXK_PAGEUP, ID_PAGE_UP)])
        self.SetAcceleratorTable(at)

        JobManager().AddVisual(self)

        self.Bind(EVT_REGISTER_JOB, self.OnRegisterJob)
        self.Bind(EVT_REMOVE_JOB, self.OnRemoveJob)
Exemplo n.º 13
0
    if not CheckFile(audioFile):
        logging.error(_(u"Audio file '%s' does not exist!"), audioFile)
        return 8

    if rendererClass is StreamRenderer:
        cliGui = DummyGui()
    else:
        cliGui = CliGui()

    cliGui.Info(options.project, rendererClass, profile)

    ar.Execute()
    renderJob = ar.GetRenderJob()
    renderJob.AddVisualJobHandler(cliGui)

    JobManager().EnqueueContext(renderJob)

    try:
        while not renderJob.IsDone():
            time.sleep(0.1)
    except KeyboardInterrupt:
        renderJob.Abort()
        cliGui.Write("\n" + _(u"...aborted!"))
        return 10

    resultObj = renderJob.GetResultObject()
    result = resultObj.GetResult()
    if result:
        cliGui.Write(_(u"all done"))