"""
import sys
-from m_lib.defenc import default_encoding
+from xsetbg_conf import xsetbg_conf
from xsetbg_db import xsetbg_db
if not xsetbg_db:
sys.exit("Error: no database found")
+fs_encoding = xsetbg_conf.get("images", "fs_encoding")
for row in xsetbg_db.select(orderBy='-last_shown'):
- print(row.id, row.last_shown, row.full_name.encode(default_encoding))
+ sys.stdout.buffer.write(
+ ('%d %s %s\n' % (row.id, row.last_shown, row.full_name
+ )).encode(fs_encoding)
+ )
filename = xsetbg_db.select('last_shown IS NOT NULL',
orderBy='-last_shown')[index].full_name
-print(filename.encode(output_encoding))
+sys.stdout.buffer.write(filename.encode(output_encoding) + b'\n')
return int(float(s))
-dump_file = open(sys.argv[1], 'r')
+dump_file = open(sys.argv[1], 'r',
+ encoding=xsetbg_conf.get("images", "fs_encoding"))
xsetbg_db = recreate_db()
count_new = count_old = count_updated = 0
-fs_encoding = xsetbg_conf.get("images", "fs_encoding")
with SQLiteMassInsert() as txn:
for line in dump_file:
id, timestamp, filename = line.strip().split(None, 2)
id = convert_str(id)
timestamp = convert_str(timestamp)
- filename = filename.decode(fs_encoding)
try:
if id:
row = xsetbg_db.get(id)
import os
import subprocess
+
from sqlobject import SQLObjectNotFound
from sqlobject.sqlbuilder import Insert, Update, Delete
+from m_lib.defenc import default_encoding
+
from xsetbg_conf import xsetbg_dir, xsetbg_conf
from xsetbg_db import recreate_db, SQLiteMassInsert
# List images in all subdirectories
for dirpath, dirs, files in os.walk(image_dir):
for file in files:
- full_name = os.path.join(dirpath, file).decode(fs_encoding)
+ if default_encoding != fs_encoding:
+ file = file.encode().decode(fs_encoding)
+ full_name = os.path.join(dirpath, file)
try:
row = xsetbg_db.byFull_name(full_name)
except SQLObjectNotFound: