]> git.phdru.name Git - xsetbg.git/commitdiff
Configure path to the database
authorOleg Broytman <phd@phdru.name>
Tue, 7 Jan 2014 10:33:08 +0000 (14:33 +0400)
committerOleg Broytman <phd@phdru.name>
Tue, 7 Jan 2014 10:33:08 +0000 (14:33 +0400)
dump_db.py
find_oldest.py
print_all.py
reload_db.py
xsetbg.conf.pat
xsetbg.py
xsetbg_db.py

index 9c4954d31370826356bb8b72d0a37b800d659caa..8c80932bb70172da338ae15a8f256c09e9cc3c15 100755 (executable)
@@ -6,19 +6,13 @@ This file is a part of XSetBg.
 """
 
 __author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 2006-2012 PhiloSoft Design"
+__copyright__ = "Copyright (C) 2006-2014 PhiloSoft Design"
 __license__ = "GNU GPL"
 
-import os, shelve
 from operator import itemgetter
+from xsetbg_db import xsetbg_db
 
-xsetbg_dir = os.path.join(os.environ["HOME"], "lib", "xsetbg")
-os.chdir(xsetbg_dir)
-
-global_db_name = "xsetbg.db"
-
-global_db = shelve.open(global_db_name, flag='r')
-for key, value in sorted(global_db.items(), key=itemgetter(1), reverse=1):
+for key, value in sorted(xsetbg_db.items(), key=itemgetter(1), reverse=1):
    if key.startswith('/'):
       print value, key
-global_db.close()
+xsetbg_db.close()
index 444abe786e30aa2a1a58d62ec10314e580414754..f98b4e6d6c051756c996019b40514bb0110dc77a 100755 (executable)
@@ -6,26 +6,20 @@ This file is a part of XSetBg.
 """
 
 __author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 2006-2012 PhiloSoft Design"
+__copyright__ = "Copyright (C) 2006-2014 PhiloSoft Design"
 __license__ = "GNU GPL"
 
-import os, shelve
 from time import localtime, asctime
-
-xsetbg_dir = os.path.join(os.environ["HOME"], "lib", "xsetbg")
-os.chdir(xsetbg_dir)
-
-global_db_name = "xsetbg.db"
+from xsetbg_db import xsetbg_db
 
 count = 0
 oldest = None
 
-global_db = shelve.open(global_db_name, flag='r')
-for key in global_db.keys():
+for key in xsetbg_db.keys():
    count += 1
-   if key.startswith('/') and ((oldest is None) or (global_db[key] < oldest)):
-      oldest = global_db[key]
-global_db.close()
+   if key.startswith('/') and ((oldest is None) or (xsetbg_db[key] < oldest)):
+      oldest = xsetbg_db[key]
+xsetbg_db.close()
 
 print count, "files"
 print "Oldest:", asctime(localtime(oldest))
index 64bc3f4fcd4e2cba5e3b483b9a7670e2277211d6..e67c642d0e2ccc247db22524cba568998fa07e6b 100755 (executable)
@@ -6,19 +6,13 @@ This file is a part of XSetBg.
 """
 
 __author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 2006-2012 PhiloSoft Design"
+__copyright__ = "Copyright (C) 2006-2014 PhiloSoft Design"
 __license__ = "GNU GPL"
 
-import os, shelve
 from operator import itemgetter
+from xsetbg_db import xsetbg_db
 
-xsetbg_dir = os.path.join(os.environ["HOME"], "lib", "xsetbg")
-os.chdir(xsetbg_dir)
-
-global_db_name = "xsetbg.db"
-
-global_db = shelve.open(global_db_name, flag='r')
-for key, value in sorted(global_db.items(), key=itemgetter(1), reverse=1):
+for key, value in sorted(xsetbg_db.items(), key=itemgetter(1), reverse=1):
    if key.startswith('/'):
       print key
-global_db.close()
+xsetbg_db.close()
index af037104762dbeab193a5ff54d4c7d3b4a1ab92c..1bee46e92dde9517f826152043dced4f5ff87469 100755 (executable)
@@ -6,20 +6,17 @@ This file is a part of XSetBg.
 """
 
 __author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 2007-2012 PhiloSoft Design"
+__copyright__ = "Copyright (C) 2007-2014 PhiloSoft Design"
 __license__ = "GNU GPL"
 
-import sys, os, shelve
+import sys, shelve
+from xsetbg_db import xsetbg_db_path
 
-xsetbg_dir = os.path.join(os.environ["HOME"], "lib", "xsetbg")
-os.chdir(xsetbg_dir)
-
-global_db_name = "xsetbg.db"
 dump_file = open(sys.argv[1], 'rU')
 
-global_db = shelve.open(global_db_name, flag='n')
+xsetbg_db = shelve.open(xsetbg_db_path, flag='n')
 for line in dump_file:
    timestamp, filename = line.strip().split(None, 1)
-   global_db[filename] = float(timestamp)
-global_db.close()
+   xsetbg_db[filename] = float(timestamp)
+xsetbg_db.close()
 dump_file.close()
index 3dd1bf58b064a48e2165d5d49faf5ad75827db63..d515443372cb12eb61266c3acd76fb657acce35c 100644 (file)
@@ -7,6 +7,8 @@ host = localhost
 port = 7999
 
 [xsetbg]
+database = ~/lib/xsetbg/xsetbg.db
+
 ; minimum time in seconds between background image changes
 min_pause = 300 ; (5 minutes)
 
index f4426ee6f121b8af3c6451345531d583e4e1f5a7..ac55e25f4271ae60c300ead1650c5287e88009a8 100755 (executable)
--- a/xsetbg.py
+++ b/xsetbg.py
@@ -26,7 +26,7 @@ import sys
 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
 
 
 def error(error_str, error_code=1):
@@ -116,11 +116,11 @@ os.umask(0066) # octal; -rw-------; make the global persistent dictionary
                # 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
@@ -164,7 +164,7 @@ def change(force=False):
    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()
index 4853afb8f75ba90a2c142020ccd60e84034bd36b..d98e1b5a3ce0cc71fbd5f9eb1ec80b2abb64d0b3 100755 (executable)
@@ -10,13 +10,12 @@ __license__ = "GNU GPL"
 __all__ = ['xsetbg_db']
 
 import anydbm
-import os
 import shelve
-from xsetbg_conf import xsetbg_dir, xsetbg_conf
+from xsetbg_conf import xsetbg_conf
 
-xsetbg_db_name = "xsetbg.db"
+xsetbg_db_path = xsetbg_conf.get('xsetbg', 'database')
 
 try:
-    xsetbg_db = shelve.open(os.path.join(xsetbg_dir, xsetbg_db_name), 'r')
+    xsetbg_db = shelve.open(xsetbg_db_path, 'r')
 except anydbm.error:
     xsetbg_db = None