[pitivi] dogtail: Tell the app to use a temporary directory for xdg user dirs
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] dogtail: Tell the app to use a temporary directory for xdg user dirs
- Date: Wed, 2 Apr 2014 15:30:02 +0000 (UTC)
commit 45b2c3c8acc9505a3e4f566f11f852b3ff14fac8
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Fri Mar 28 01:06:38 2014 +0100
dogtail: Tell the app to use a temporary directory for xdg user dirs
pitivi/settings.py | 24 ++++++++++++++++++------
tests/dogtail_scripts/common.py | 20 +++++++++++++++++---
tests/dogtail_scripts/test_medialibrary.py | 2 +-
tests/dogtail_scripts/test_project.py | 1 -
4 files changed, 36 insertions(+), 11 deletions(-)
---
diff --git a/pitivi/settings.py b/pitivi/settings.py
index 311f216..b324f8a 100644
--- a/pitivi/settings.py
+++ b/pitivi/settings.py
@@ -67,18 +67,30 @@ def get_dir(path, autocreate=True):
def xdg_config_home(autocreate=True):
- """Get the directory for storing the user's pitivi configuration"""
- return get_dir(os.path.join(GLib.get_user_config_dir(), "pitivi"), autocreate)
+ """
+ Get the directory for storing the user's pitivi configuration
+ """
+ default = os.path.join(GLib.get_user_config_dir(), "pitivi")
+ path = os.getenv("PITIVI_USER_CONFIG_DIR", default)
+ return get_dir(path, autocreate)
def xdg_data_home(autocreate=True):
- """Get the directory for storing the user's data: presets, plugins, etc."""
- return get_dir(os.path.join(GLib.get_user_data_dir(), "pitivi"), autocreate)
+ """
+ Get the directory for storing the user's data: presets, plugins, etc.
+ """
+ default = os.path.join(GLib.get_user_data_dir(), "pitivi")
+ path = os.getenv("PITIVI_USER_DATA_DIR", default)
+ return get_dir(path, autocreate)
def xdg_cache_home(autocreate=True):
- """Get the Pitivi cache directory"""
- return get_dir(os.path.join(GLib.get_user_cache_dir(), "pitivi"), autocreate)
+ """
+ Get the Pitivi cache directory
+ """
+ default = os.path.join(GLib.get_user_cache_dir(), "pitivi")
+ path = os.getenv("PITIVI_USER_CACHE_DIR", default)
+ return get_dir(path, autocreate)
class ConfigError(Exception):
diff --git a/tests/dogtail_scripts/common.py b/tests/dogtail_scripts/common.py
index eee19a4..91fd47a 100644
--- a/tests/dogtail_scripts/common.py
+++ b/tests/dogtail_scripts/common.py
@@ -3,6 +3,8 @@
import os
import re
+import shutil
+import tempfile
import time
import unittest
@@ -36,6 +38,13 @@ class PitiviTestCase(unittest.TestCase):
'runTimeout': 1,
'searchCutoffCount': 5,
'defaultDelay': 0.1})
+ # Specify custom xdg user dirs to not be influenced by the settings
+ # chosen by the current user.
+ if not hasattr(self, "user_dir"):
+ self.user_dir = tempfile.mkdtemp()
+ os.environ["PITIVI_USER_CONFIG_DIR"] = os.path.pathsep.join([self.user_dir, "config"])
+ os.environ["PITIVI_USER_DATA_DIR"] = os.path.pathsep.join([self.user_dir, "data"])
+ os.environ["PITIVI_USER_CACHE_DIR"] = os.path.pathsep.join([self.user_dir, "cache"])
from dogtail.utils import run
from dogtail.tree import root
# Setting appName is critically important here.
@@ -52,7 +61,6 @@ class PitiviTestCase(unittest.TestCase):
# This is a performance hack to very quickly get the widgets we want,
# by using their known position instead of searching.
# Reuse those variables throughout your scripts for efficient access.
- # FIXME: this will probably break with detached tabs.
mainwindow = self.pitivi.children[0].children[0].children[0] # this is a vbox
assert mainwindow.name == 'contents'
mainwindow_upper, timeline_area = mainwindow.children
@@ -92,11 +100,17 @@ class PitiviTestCase(unittest.TestCase):
import dogtail.rawinput
dogtail.rawinput.keyCombo("<Control>q") # Quit the app
if clean:
+ try:
+ shutil.rmtree(self.user_dir)
+ except OSError:
+ # No biggie.
+ pass
for filename in self.unlink:
try:
os.unlink(filename)
- except:
- None
+ except OSError:
+ # No biggie.
+ pass
def saveProject(self, path=None, saveAs=True):
if saveAs:
diff --git a/tests/dogtail_scripts/test_medialibrary.py b/tests/dogtail_scripts/test_medialibrary.py
index 416ca15..95096bf 100644
--- a/tests/dogtail_scripts/test_medialibrary.py
+++ b/tests/dogtail_scripts/test_medialibrary.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python2
+
from common import PitiviTestCase
from time import sleep
@@ -10,7 +11,6 @@ class MediaLibraryTest(PitiviTestCase):
search = self.medialibrary.child(name="media_search_entry", roleName="text")
unused_media_button = search.child(name="starred-symbolic", roleName="icon")
- # FIXME: this test would fail in listview mode - for now we just force iconview mode.
self.force_medialibrary_iconview_mode()
samples = []
diff --git a/tests/dogtail_scripts/test_project.py b/tests/dogtail_scripts/test_project.py
index dfa77fe..2cae069 100644
--- a/tests/dogtail_scripts/test_project.py
+++ b/tests/dogtail_scripts/test_project.py
@@ -158,7 +158,6 @@ class ProjectPropertiesTest(PitiviTestCase):
self.assertIn("37:20", childtext, "Display aspect ratio was not saved")
def test_backup(self):
- # FIXME: this test would fail in listview mode - for now we just force iconview mode.
self.force_medialibrary_iconview_mode()
# Import a clip into an empty project and save the project
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]