def __init__(self): Loggable.__init__(self) # Init logging as early as possible so we can log startup code enable_color = not os.environ.get('PITIVI_DEBUG_NO_COLOR', '0') in ('', '1') # Let's show a human-readable pitivi debug output by default, and only # show a crazy unreadable mess when surrounded by gst debug statements. enable_crack_output = "GST_DEBUG" in os.environ log.init('PITIVI_DEBUG', enable_color, enable_crack_output) self.info('starting up') self.settings = GlobalSettings() self.threads = ThreadMaster() self.effects = EffectsHandler() self.system = getSystem() self.current_project = None self.projectManager = ProjectManager(self) self._connectToProjectManager(self.projectManager) self.action_log = UndoableActionLog() self.debug_action_log_observer = DebugActionLogObserver() self.debug_action_log_observer.startObserving(self.action_log) # TODO reimplement the observing after GES port #self.timelineLogObserver = TimelineLogObserver(self.action_log) self.projectLogObserver = ProjectLogObserver(self.action_log) self._version_information = {} self._checkVersion()
def __init__(self): """ initialize pitivi with the command line arguments """ Loggable.__init__(self) # init logging as early as possible so we can log startup code enable_color = os.environ.get('PITIVI_DEBUG_NO_COLOR', '0') in ('', '0') # Let's show a human-readable pitivi debug output by default, and only # show a crazy unreadable mess when surrounded by gst debug statements. enable_crack_output = "GST_DEBUG" in os.environ log.init('PITIVI_DEBUG', enable_color, enable_crack_output) self.info('starting up') # store ourself in the instance global if instance.PiTiVi: raise RuntimeWarning( _("There is already a %s instance, please inform " "the developers by filing a bug at " "http://bugzilla.gnome.org/enter_bug.cgi?product=pitivi") % APPNAME) instance.PiTiVi = self self.current = None # get settings self.settings = GlobalSettings() self.threads = ThreadMaster() #self.screencast = False self.effects = EffectsHandler() self.system = getSystem() self.projectManager = ProjectManager(self) self._connectToProjectManager(self.projectManager) self.action_log = UndoableActionLog() self.debug_action_log_observer = DebugActionLogObserver() self.debug_action_log_observer.startObserving(self.action_log) # TODO reimplement the observing after GES port #self.timelineLogObserver = TimelineLogObserver(self.action_log) self.projectLogObserver = ProjectLogObserver(self.action_log) self.version_information = {} self._checkVersion()
def __init__(self): """ initialize pitivi with the command line arguments """ Loggable.__init__(self) # init logging as early as possible so we can log startup code enable_color = os.environ.get('PITIVI_DEBUG_NO_COLOR', '0') in ('', '0') # Let's show a human-readable pitivi debug output by default, and only # show a crazy unreadable mess when surrounded by gst debug statements. enable_crack_output = "GST_DEBUG" in os.environ log.init('PITIVI_DEBUG', enable_color, enable_crack_output) self.info('starting up') # store ourself in the instance global if instance.PiTiVi: raise RuntimeWarning(_("There is already a %s instance, please inform " "the developers by filing a bug at " "http://bugzilla.gnome.org/enter_bug.cgi?product=pitivi") % APPNAME) instance.PiTiVi = self self.current = None # get settings self.settings = GlobalSettings() self.threads = ThreadMaster() #self.screencast = False self.effects = EffectsHandler() self.system = getSystem() self.projectManager = ProjectManager(self.effects) self._connectToProjectManager(self.projectManager) self.action_log = UndoableActionLog() self.debug_action_log_observer = DebugActionLogObserver() self.debug_action_log_observer.startObserving(self.action_log) # TODO reimplement the observing after GES port #self.timelineLogObserver = TimelineLogObserver(self.action_log) self.projectLogObserver = ProjectLogObserver(self.action_log) self.medialibrary_log_observer = MediaLibraryLogObserver(self.action_log) self.version_information = {} self._checkVersion()
class Pitivi(Loggable, Signallable): """ Pitivi's main application class. Signals: - C{new-project} : A new C{Project} is loaded and ready to use. - C{new-project-loading} : Pitivi is attempting to load a new project. - C{new-project-loaded} : A new L{Project} has been loaded, and the UI should refresh it's view. - C{new-project-failed} : A new L{Project} failed to load. - C{closing-project} : pitivi would like to close a project. handlers should return false if they do not want this project to close. by default, assumes true. This signal should only be used by classes that might want to abort the closing of a project. - C{project-closed} : The project is closed, it will be freed when the callback returns. Classes should connect to this instance when they want to know that data related to that project is no longer going to be used. - C{shutdown} : Used internally, do not use this signal.` @ivar settings: Application-wide settings. @type settings: L{GlobalSettings}. @ivar current: Currently used project. @type current: L{Project}. """ __signals__ = { "new-project": ["project"], "new-project-loading": ["uri"], "new-project-created": ["project"], "new-project-loaded": ["project"], "new-project-failed": ["uri", "exception"], "closing-project": ["project"], "project-closed": ["project"], "missing-uri": ["formatter", "uri"], "version-info-received": ["versions"], "shutdown": None} def __init__(self): """ initialize pitivi with the command line arguments """ Loggable.__init__(self) # init logging as early as possible so we can log startup code enable_color = os.environ.get('PITIVI_DEBUG_NO_COLOR', '0') in ('', '0') # Let's show a human-readable pitivi debug output by default, and only # show a crazy unreadable mess when surrounded by gst debug statements. enable_crack_output = "GST_DEBUG" in os.environ log.init('PITIVI_DEBUG', enable_color, enable_crack_output) self.info('starting up') # store ourself in the instance global if instance.PiTiVi: raise RuntimeWarning(_("There is already a %s instance, please inform " "the developers by filing a bug at " "http://bugzilla.gnome.org/enter_bug.cgi?product=pitivi") % APPNAME) instance.PiTiVi = self self.current = None # get settings self.settings = GlobalSettings() self.threads = ThreadMaster() #self.screencast = False self.effects = EffectsHandler() self.system = getSystem() self.projectManager = ProjectManager(self.effects) self._connectToProjectManager(self.projectManager) self.action_log = UndoableActionLog() self.debug_action_log_observer = DebugActionLogObserver() self.debug_action_log_observer.startObserving(self.action_log) # TODO reimplement the observing after GES port #self.timelineLogObserver = TimelineLogObserver(self.action_log) self.projectLogObserver = ProjectLogObserver(self.action_log) self.medialibrary_log_observer = MediaLibraryLogObserver(self.action_log) self.version_information = {} self._checkVersion() def shutdown(self): """ Close PiTiVi. @return: C{True} if PiTiVi was successfully closed, else C{False}. @rtype: C{bool} """ self.debug("shutting down") # we refuse to close if we're running a user interface and the user # doesn't want us to close the current project. if self.current and not self.projectManager.closeRunningProject(): self.warning("Not closing since running project doesn't want to close") return False self.threads.stopAllThreads() self.settings.storeSettings() self.current = None instance.PiTiVi = None self.emit("shutdown") return True def _connectToProjectManager(self, projectManager): projectManager.connect("new-project-loading", self._projectManagerNewProjectLoading) projectManager.connect("new-project-created", self._projectManagerNewProjectCreated) projectManager.connect("new-project-loaded", self._projectManagerNewProjectLoaded) projectManager.connect("new-project-failed", self._projectManagerNewProjectFailed) projectManager.connect("closing-project", self._projectManagerClosingProject) projectManager.connect("project-closed", self._projectManagerProjectClosed) def _projectManagerNewProjectLoading(self, projectManager, uri): self.emit("new-project-loading", uri) def _projectManagerNewProjectCreated(self, projectManager, project): self.current = project self.emit("new-project-created", project) def _newProjectLoaded(self, project): pass def _projectManagerNewProjectLoaded(self, projectManager, project): self.current = project self.action_log.clean() #self.timelineLogObserver.startObserving(project.timeline) self.projectLogObserver.startObserving(project) self.medialibrary_log_observer.startObserving(project.medialibrary) self._newProjectLoaded(project) self.emit("new-project-loaded", project) def _projectManagerNewProjectFailed(self, projectManager, uri, exception): self.emit("new-project-failed", uri, exception) def _projectManagerClosingProject(self, projectManager, project): return self.emit("closing-project", project) def _projectManagerProjectClosed(self, projectManager, project): #self.timelineLogObserver.stopObserving(project.timeline) self.projectLogObserver.stopObserving(project) self.current = None self.emit("project-closed", project) # check if for version information online def _checkVersion(self): giofile = Gio.File.new_for_uri(RELEASES_URL) self.info("Requesting version information") giofile.load_contents_async(None, self._versionInfoReceivedCb, None) def _versionInfoReceivedCb(self, giofile, result, data): try: # split data in lines raw = giofile.load_contents_finish(result)[0].split("\n") # split line at '=' if not empty or comment data = [element.split("=") for element in raw if element and not element.startswith("#")] # search newest version and status status = "UNSUPPORTED" for version, version_status in data: if pitivi_version == version: status = version_status if version_status.upper() == "CURRENT": current_version = version self.info("Version information received") self.version_information["current"] = current_version self.version_information["status"] = status self.emit("version-info-received", self.version_information) except: self.warning("Version information could not be read")
class Pitivi(Loggable, Signallable): """ Pitivi's main application class. Signals: - C{new-project} : A new C{Project} is loaded and ready to use. - C{new-project-loading} : Pitivi is attempting to load a new project. - C{new-project-loaded} : A new L{Project} has been loaded, and the UI should refresh it's view. - C{new-project-failed} : A new L{Project} failed to load. - C{project-closed} : The project is closed, it will be freed when the callback returns. Classes should connect to this instance when they want to know that data related to that project is no longer going to be used. - C{shutdown} : Used internally, do not use this signal.` @ivar settings: Application-wide settings. @type settings: L{GlobalSettings}. @ivar current: Currently used project. @type current: L{Project}. """ __signals__ = { "new-project": ["project"], "new-project-loading": ["uri"], "new-project-created": ["project"], "new-project-loaded": ["project"], "new-project-failed": ["uri", "exception"], "project-closed": ["project"], "missing-uri": ["formatter", "uri"], "version-info-received": ["versions"], "shutdown": None} def __init__(self): Loggable.__init__(self) # Init logging as early as possible so we can log startup code enable_color = not os.environ.get('PITIVI_DEBUG_NO_COLOR', '0') in ('', '1') # Let's show a human-readable pitivi debug output by default, and only # show a crazy unreadable mess when surrounded by gst debug statements. enable_crack_output = "GST_DEBUG" in os.environ log.init('PITIVI_DEBUG', enable_color, enable_crack_output) self.info('starting up') self.settings = GlobalSettings() self.threads = ThreadMaster() self.effects = EffectsHandler() self.system = getSystem() self.current_project = None self.projectManager = ProjectManager(self) self._connectToProjectManager(self.projectManager) self.action_log = UndoableActionLog() self.debug_action_log_observer = DebugActionLogObserver() self.debug_action_log_observer.startObserving(self.action_log) # TODO reimplement the observing after GES port #self.timelineLogObserver = TimelineLogObserver(self.action_log) self.projectLogObserver = ProjectLogObserver(self.action_log) self._version_information = {} self._checkVersion() def shutdown(self): """ Close Pitivi. @return: C{True} if Pitivi was successfully closed, else C{False}. @rtype: C{bool} """ self.debug("shutting down") # we refuse to close if we're running a user interface and the user # doesn't want us to close the current project. if self.current_project and not self.projectManager.closeRunningProject(): self.warning("Not closing since running project doesn't want to close") return False self.threads.stopAllThreads() self.settings.storeSettings() self.current_project = None self.emit("shutdown") return True def _connectToProjectManager(self, projectManager): pm = projectManager pm.connect("new-project-loading", self._projectManagerNewProjectLoading) pm.connect("new-project-created", self._projectManagerNewProjectCreated) pm.connect("new-project-loaded", self._projectManagerNewProjectLoaded) pm.connect("new-project-failed", self._projectManagerNewProjectFailed) pm.connect("project-closed", self._projectManagerProjectClosed) def _projectManagerNewProjectLoading(self, unused_project_manager, uri): self.emit("new-project-loading", uri) def _projectManagerNewProjectCreated(self, unused_project_manager, project): self.current_project = project self.emit("new-project-created", project) def _newProjectLoaded(self, unused_project): pass def _projectManagerNewProjectLoaded(self, unused_project_manager, project, unused_fully_loaded): self.current_project = project self.action_log.clean() #self.timelineLogObserver.startObserving(project.timeline) self.projectLogObserver.startObserving(project) self._newProjectLoaded(project) self.emit("new-project-loaded", project) def _projectManagerNewProjectFailed(self, unused_project_manager, uri, exception): self.emit("new-project-failed", uri, exception) def _projectManagerProjectClosed(self, unused_project_manager, project): #self.timelineLogObserver.stopObserving(project.timeline) self.projectLogObserver.stopObserving(project) self.current_project = None self.emit("project-closed", project) def _checkVersion(self): # Check online for release versions information giofile = Gio.File.new_for_uri(RELEASES_URL) self.info("Requesting version information") giofile.load_contents_async(None, self._versionInfoReceivedCb, None) def _versionInfoReceivedCb(self, giofile, result, user_data): try: raw = giofile.load_contents_finish(result)[1] raw = raw.split("\n") # Split line at '=' if the line is not empty or a comment line data = [element.split("=") for element in raw if element and not element.startswith("#")] # search newest version and status status = "UNSUPPORTED" current_version = None for version, version_status in data: if VERSION == version: status = version_status if version_status.upper() == "CURRENT": # This is the latest. current_version = version self.info("Latest software version is %s", current_version) if status is "UNSUPPORTED": self.warning("Using an outdated version of Pitivi (%s)", VERSION) self._version_information["current"] = current_version self._version_information["status"] = status self.emit("version-info-received", self._version_information) except Exception, e: self.warning("Version info could not be read: %s", e)
class Pitivi(Loggable, Signallable): """ Pitivi's main application class. Signals: - C{new-project} : A new C{Project} is loaded and ready to use. - C{new-project-loading} : Pitivi is attempting to load a new project. - C{new-project-loaded} : A new L{Project} has been loaded, and the UI should refresh it's view. - C{new-project-failed} : A new L{Project} failed to load. - C{closing-project} : pitivi would like to close a project. handlers should return false if they do not want this project to close. by default, assumes true. This signal should only be used by classes that might want to abort the closing of a project. - C{project-closed} : The project is closed, it will be freed when the callback returns. Classes should connect to this instance when they want to know that data related to that project is no longer going to be used. - C{shutdown} : Used internally, do not use this signal.` @ivar settings: Application-wide settings. @type settings: L{GlobalSettings}. @ivar current: Currently used project. @type current: L{Project}. """ __signals__ = { "new-project": ["project"], "new-project-loading": ["uri"], "new-project-created": ["project"], "new-project-loaded": ["project"], "new-project-failed": ["uri", "exception"], "closing-project": ["project"], "project-closed": ["project"], "missing-uri": ["formatter", "uri"], "version-info-received": ["versions"], "shutdown": None } def __init__(self): """ initialize pitivi with the command line arguments """ Loggable.__init__(self) # init logging as early as possible so we can log startup code enable_color = os.environ.get('PITIVI_DEBUG_NO_COLOR', '0') in ('', '0') # Let's show a human-readable pitivi debug output by default, and only # show a crazy unreadable mess when surrounded by gst debug statements. enable_crack_output = "GST_DEBUG" in os.environ log.init('PITIVI_DEBUG', enable_color, enable_crack_output) self.info('starting up') # store ourself in the instance global if instance.PiTiVi: raise RuntimeWarning( _("There is already a %s instance, please inform " "the developers by filing a bug at " "http://bugzilla.gnome.org/enter_bug.cgi?product=pitivi") % APPNAME) instance.PiTiVi = self self.current = None # get settings self.settings = GlobalSettings() self.threads = ThreadMaster() #self.screencast = False self.effects = EffectsHandler() self.system = getSystem() self.projectManager = ProjectManager(self) self._connectToProjectManager(self.projectManager) self.action_log = UndoableActionLog() self.debug_action_log_observer = DebugActionLogObserver() self.debug_action_log_observer.startObserving(self.action_log) # TODO reimplement the observing after GES port #self.timelineLogObserver = TimelineLogObserver(self.action_log) self.projectLogObserver = ProjectLogObserver(self.action_log) self.version_information = {} self._checkVersion() def shutdown(self): """ Close PiTiVi. @return: C{True} if PiTiVi was successfully closed, else C{False}. @rtype: C{bool} """ self.debug("shutting down") # we refuse to close if we're running a user interface and the user # doesn't want us to close the current project. if self.current and not self.projectManager.closeRunningProject(): self.warning( "Not closing since running project doesn't want to close") return False self.threads.stopAllThreads() self.settings.storeSettings() self.current = None instance.PiTiVi = None self.emit("shutdown") return True def _connectToProjectManager(self, projectManager): pm = projectManager pm.connect("new-project-loading", self._projectManagerNewProjectLoading) pm.connect("new-project-created", self._projectManagerNewProjectCreated) pm.connect("new-project-loaded", self._projectManagerNewProjectLoaded) pm.connect("new-project-failed", self._projectManagerNewProjectFailed) pm.connect("closing-project", self._projectManagerClosingProject) pm.connect("project-closed", self._projectManagerProjectClosed) def _projectManagerNewProjectLoading(self, projectManager, uri): self.emit("new-project-loading", uri) def _projectManagerNewProjectCreated(self, projectManager, project): self.current = project self.emit("new-project-created", project) def _newProjectLoaded(self, project): pass def _projectManagerNewProjectLoaded(self, projectManager, project, unused_fully_loaded): self.current = project self.action_log.clean() #self.timelineLogObserver.startObserving(project.timeline) self.projectLogObserver.startObserving(project) self._newProjectLoaded(project) self.emit("new-project-loaded", project) def _projectManagerNewProjectFailed(self, projectManager, uri, exception): self.emit("new-project-failed", uri, exception) def _projectManagerClosingProject(self, projectManager, project): return self.emit("closing-project", project) def _projectManagerProjectClosed(self, projectManager, project): #self.timelineLogObserver.stopObserving(project.timeline) self.projectLogObserver.stopObserving(project) self.current = None self.emit("project-closed", project) # check if for version information online def _checkVersion(self): giofile = Gio.File.new_for_uri(RELEASES_URL) self.info("Requesting version information") giofile.load_contents_async(None, self._versionInfoReceivedCb, None) def _versionInfoReceivedCb(self, giofile, result, data): try: # split data in lines raw = giofile.load_contents_finish(result)[0].split("\n") # split line at '=' if not empty or comment data = [ element.split("=") for element in raw if element and not element.startswith("#") ] # search newest version and status status = "UNSUPPORTED" for version, version_status in data: if pitivi_version == version: status = version_status if version_status.upper() == "CURRENT": current_version = version self.info("Version information received") self.version_information["current"] = current_version self.version_information["status"] = status self.emit("version-info-received", self.version_information) except: self.warning("Version information could not be read")