Merge lp:~sylvain-pineau/checkbox/session-in-cache-dir into lp:checkbox

Proposed by Sylvain Pineau
Status: Merged
Approved by: Zygmunt Krynicki
Approved revision: 1899
Merged at revision: 1899
Proposed branch: lp:~sylvain-pineau/checkbox/session-in-cache-dir
Merge into: lp:checkbox
Diff against target: 32 lines (+10/-3)
1 file modified
plainbox/plainbox/impl/session.py (+10/-3)
To merge this branch: bzr merge lp:~sylvain-pineau/checkbox/session-in-cache-dir
Reviewer Review Type Date Requested Status
Zygmunt Krynicki (community) Approve
Review via email: mp+144475@code.launchpad.net

Description of the change

MR for plainbox, use XDG_CACHE_HOME to store the session data

To post a comment you must log in.
1899. By Sylvain Pineau

Use XDG_CACHE_HOME to compute session_dir

This directory is also going to be used for CHECKBOX_DATA
Note: XDG_CACHE_HOME definition borrowed from python3-xdg

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

+1

Accepted during hangout review process

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plainbox/plainbox/impl/session.py'
2--- plainbox/plainbox/impl/session.py 2012-11-29 18:59:46 +0000
3+++ plainbox/plainbox/impl/session.py 2013-01-23 11:10:30 +0000
4@@ -27,6 +27,7 @@
5 """
6 import logging
7 import shutil
8+import os
9 import tempfile
10
11 from plainbox.impl.depmgr import DependencyError
12@@ -300,11 +301,17 @@
13 """
14 Open session state for running jobs.
15
16- This function creates a temporary directory where jobs can store their
17- temporary data. This directory will be removed by .close()
18+ This function creates the cache directory where jobs can store their
19+ data. See:
20+ http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
21 """
22 if self._session_dir is None:
23- self._session_dir = tempfile.mkdtemp()
24+ xdg_cache_home = os.environ.get('XDG_CACHE_HOME') or \
25+ os.path.join(os.path.expanduser('~'), '.cache')
26+ temp_dir = os.path.join(xdg_cache_home, 'plainbox')
27+ if not os.path.isdir(temp_dir):
28+ os.makedirs(temp_dir)
29+ self._session_dir = tempfile.mkdtemp(dir=temp_dir)
30 return self
31
32 def close(self):

Subscribers

People subscribed via source and target branches