~aaronp/software-center/enhance-usefulness

« back to all changes in this revision

Viewing changes to softwarecenter/log.py

  • Committer: Michael Vogt
  • Date: 2011-04-19 18:15:39 UTC
  • Revision ID: michael.vogt@ubuntu.com-20110419181539-272co2435ccy67fv
softwarecenter/log.py: just try the rename 10 times, we should never need this more than once, if we need that many renames it should crash for the user so that we learn what is going wrong

Show diffs side-by-side

added added

removed removed

Lines of Context:
93
93
# try to fix inaccessible s-c directory (#688682)
94
94
if not os.access(SOFTWARE_CENTER_CACHE_DIR, os.W_OK):
95
95
    logging.warn("found not writable '%s' dir, trying to fix" % SOFTWARE_CENTER_CACHE_DIR)
96
 
    i = 0
97
 
    while True:
 
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):
98
99
        target = "%s.%s" % (SOFTWARE_CENTER_CACHE_DIR, i)
99
100
        if not os.path.exists(target):
100
101
            os.rename(SOFTWARE_CENTER_CACHE_DIR, target)
101
102
            break
102
 
        i += 1
103
103
    os.makedirs(SOFTWARE_CENTER_CACHE_DIR)
104
104
 
105
105
# according to bug 688682 many people have a non-writeable logfile