~ubuntu-branches/ubuntu/natty/software-center/natty

« back to all changes in this revision

Viewing changes to softwarecenter/log.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2011-04-19 20:31:31 UTC
  • Revision ID: james.westby@ubuntu.com-20110419203131-n3l1p78csr3n48xb
Tags: 3.1.26.8
* softwarecenter/log.py:
  - deal with not accessible ~/.cache/software-center directory
    (LP: #688682)
* softwarecenter/paths.py:
  - check for SUDO_USER before xdg is imported, otherwise the
    check has no effect (LP: #688682)
* softwarecenter/{paths,enums}.py, utils/update-software-center-agent:
  - remove unneeded xdg.BaseDirectory import
* utils/update-software-center-agent, softwarecenter/enums.py:
  - remove unused imports, make imports explicit (thanks pyflakes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
    os.makedirs(SOFTWARE_CENTER_CACHE_DIR)
91
91
logfile_path = os.path.join(SOFTWARE_CENTER_CACHE_DIR, "software-center.log")
92
92
 
 
93
# try to fix inaccessible s-c directory (#688682)
 
94
if not os.access(SOFTWARE_CENTER_CACHE_DIR, os.W_OK):
 
95
    logging.warn("found not writable '%s' dir, trying to fix" % SOFTWARE_CENTER_CACHE_DIR)
 
96
    # if we have to do more renames, soemthing else is wrong and its
 
97
    # ok to crash later to learn about the problem
 
98
    for i in range(10):
 
99
        target = "%s.%s" % (SOFTWARE_CENTER_CACHE_DIR, i)
 
100
        if not os.path.exists(target):
 
101
            os.rename(SOFTWARE_CENTER_CACHE_DIR, target)
 
102
            break
 
103
    os.makedirs(SOFTWARE_CENTER_CACHE_DIR)
 
104
 
93
105
# according to bug 688682 many people have a non-writeable logfile
94
106
if os.path.exists(logfile_path) and not os.access(logfile_path, os.W_OK):
95
107
    try: