本文整理匯總了Python中pitivi.project.ProjectManager._makeBackupURI方法的典型用法代碼示例。如果您正苦於以下問題:Python ProjectManager._makeBackupURI方法的具體用法?Python ProjectManager._makeBackupURI怎麽用?Python ProjectManager._makeBackupURI使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pitivi.project.ProjectManager
的用法示例。
在下文中一共展示了ProjectManager._makeBackupURI方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestProjectManager
# 需要導入模塊: from pitivi.project import ProjectManager [as 別名]
# 或者: from pitivi.project.ProjectManager import _makeBackupURI [as 別名]
#.........這裏部分代碼省略.........
name, args = self.signals[1]
self.assertEqual("project-closed", name)
project = args[0]
self.assertTrue(project is current)
self.assertTrue(self.manager.current_project is None)
def testNewBlankProjectCantCloseCurrent(self):
def closing(manager, project):
return False
self.manager.current_project = MockProject()
self.manager.current_project.uri = "file:///ciao"
self.manager.connect("closing-project", closing)
self.assertFalse(self.manager.newBlankProject())
self.assertEqual(1, len(self.signals))
signal, args = self.signals[0]
self.assertEqual("closing-project", signal)
def testNewBlankProject(self):
self.assertTrue(self.manager.newBlankProject())
self.assertEqual(3, len(self.signals))
name, args = self.signals[0]
self.assertEqual("new-project-loading", name)
uri = args[0]
self.assertTrue(uri is None)
name, args = self.signals[1]
self.assertEqual("new-project-created", name)
project = args[0]
self.assertEqual(uri, project.uri)
name, args = self.signals[2]
self.assertEqual("new-project-loaded", name)
project = args[0]
self.assertTrue(project is self.manager.current_project)
def testSaveProject(self):
self.assertTrue(self.manager.newBlankProject())
unused, path = tempfile.mkstemp(suffix=".xges")
unused, path2 = tempfile.mkstemp(suffix=".xges")
try:
uri = "file://" + os.path.abspath(path)
uri2 = "file://" + os.path.abspath(path2)
# Save the project.
self.assertTrue(self.manager.saveProject(uri=uri, backup=False))
self.assertTrue(uri_is_reachable(uri))
# Wait a bit.
time.sleep(0.1)
# Save the project at a new location.
self.assertTrue(self.manager.saveProject(uri2, backup=False))
self.assertTrue(uri_is_reachable(uri2))
# Make sure the old path and the new path have different mtimes.
mtime = os.path.getmtime(path)
mtime2 = os.path.getmtime(path2)
self.assertLess(mtime, mtime2)
# Wait a bit more.
time.sleep(0.1)
# Save project again under the new path (by omitting uri arg)
self.assertTrue(self.manager.saveProject(backup=False))
# regression test for bug 594396
# make sure we didn't save to the old URI
self.assertEqual(mtime, os.path.getmtime(path))
# make sure we did save to the new URI
self.assertLess(mtime2, os.path.getmtime(path2))
finally:
os.remove(path)
os.remove(path2)
def testMakeBackupUri(self):
uri = "file:///tmp/x.xges"
self.assertEqual(uri + "~", self.manager._makeBackupURI(uri))
def testBackupProject(self):
self.manager.newBlankProject()
# Assign an uri to the project where it's saved by default.
unused, xges_path = tempfile.mkstemp(suffix=".xges")
uri = "file://" + os.path.abspath(xges_path)
self.manager.current_project.uri = uri
# This is where the automatic backup file is saved.
backup_uri = self.manager._makeBackupURI(uri)
# Save the backup
self.assertTrue(self.manager.saveProject(
self.manager.current_project, backup=True))
self.assertTrue(uri_is_reachable(backup_uri))
self.manager.closeRunningProject()
self.assertFalse(uri_is_reachable(backup_uri),
"Backup file not deleted when project closed")
示例2: TestProjectManager
# 需要導入模塊: from pitivi.project import ProjectManager [as 別名]
# 或者: from pitivi.project.ProjectManager import _makeBackupURI [as 別名]
#.........這裏部分代碼省略.........
def testCloseRunningProject(self):
current = mock.Mock()
current.uri = None
self.manager.current_project = current
self.assertTrue(self.manager.closeRunningProject())
self.assertEqual(2, len(self.signals))
name, args = self.signals[0]
self.assertEqual("closing-project", name)
project = args[0]
self.assertTrue(project is current)
name, args = self.signals[1]
self.assertEqual("project-closed", name)
project = args[0]
self.assertTrue(project is current)
self.assertTrue(self.manager.current_project is None)
def testNewBlankProject(self):
self.assertIsNotNone(self.manager.new_blank_project())
self.assertEqual(3, len(self.signals))
name, args = self.signals[0]
self.assertEqual("new-project-loading", name)
project = args[0]
self.assertTrue(project.get_uri() is None)
name, args = self.signals[1]
self.assertEqual("new-project-created", name)
project = args[0]
self.assertEqual(project.get_uri(), project.uri)
name, args = self.signals[2]
self.assertEqual("new-project-loaded", name)
project = args[0]
self.assertTrue(project is self.manager.current_project)
def testSaveProject(self):
self.manager.new_blank_project()
unused, path = tempfile.mkstemp(suffix=".xges")
unused, path2 = tempfile.mkstemp(suffix=".xges")
try:
uri = "file://" + os.path.abspath(path)
uri2 = "file://" + os.path.abspath(path2)
# Save the project.
self.assertTrue(self.manager.saveProject(uri=uri, backup=False))
self.assertTrue(os.path.isfile(path))
# Wait a bit.
time.sleep(0.1)
# Save the project at a new location.
self.assertTrue(self.manager.saveProject(uri2, backup=False))
self.assertTrue(os.path.isfile(path2))
# Make sure the old path and the new path have different mtimes.
mtime = os.path.getmtime(path)
mtime2 = os.path.getmtime(path2)
self.assertLess(mtime, mtime2)
# Wait a bit more.
time.sleep(0.1)
# Save project again under the new path (by omitting uri arg)
self.assertTrue(self.manager.saveProject(backup=False))
# regression test for bug 594396
# make sure we didn't save to the old URI
self.assertEqual(mtime, os.path.getmtime(path))
# make sure we did save to the new URI
self.assertLess(mtime2, os.path.getmtime(path2))
finally:
os.remove(path)
os.remove(path2)
def testMakeBackupUri(self):
uri = "file:///tmp/x.xges"
self.assertEqual(uri + "~", self.manager._makeBackupURI(uri))
def testBackupProject(self):
self.manager.new_blank_project()
# Assign an uri to the project where it's saved by default.
unused, xges_path = tempfile.mkstemp(suffix=".xges")
uri = "file://" + os.path.abspath(xges_path)
self.manager.current_project.uri = uri
# This is where the automatic backup file is saved.
backup_uri = self.manager._makeBackupURI(uri)
# Save the backup
self.assertTrue(self.manager.saveProject(
self.manager.current_project, backup=True))
self.assertTrue(os.path.isfile(path_from_uri(backup_uri)))
self.manager.closeRunningProject()
self.assertFalse(os.path.isfile(path_from_uri(backup_uri)),
"Backup file not deleted when project closed")