from time import time
from xsetbg_conf import xsetbg_dir, xsetbg_conf
-from xsetbg_db import xsetbg_db_name, xsetbg_db
+from xsetbg_db import xsetbg_db_path
def error(error_str, error_code=1):
# readable only by the user
try:
- xsetbg_db = shelve.open(os.path.join(xsetbg_dir, xsetbg_db_name), flag='c')
+ xsetbg_db = shelve.open(xsetbg_db_path, flag='c')
except anydbm.error, msg:
if str(msg) == "db type could not be determined":
- os.remove(xsetbg_db_name)
- xsetbg_db = shelve.open(os.path.join(xsetbg_dir, xsetbg_db_name), flag='c')
+ os.remove(xsetbg_db_path)
+ xsetbg_db = shelve.open(xsetbg_db_path, flag='c')
# Remove old filenames
old_time = time() - min_delay
def change(force=False):
# Use the program's file as the lock file:
# lock it to prevent two processes run in parallel.
- lock_file = open("xsetbg.py", 'r')
+ lock_file = open(os.path.join(xsetbg_dir, 'xsetbg.py'), 'r')
+
try:
flock(lock_file, LOCK_EX|LOCK_NB)
except IOError: # already locked
xsetbg_db = None
try:
# Reopen the global persistent dictionary
- xsetbg_db = shelve.open(os.path.join(xsetbg_dir, xsetbg_db_name), 'w')
+ xsetbg_db = shelve.open(xsetbg_db_path, 'w')
timestamp = xsetbg_db.get(timestamp_key)
current_time = time()