· 8 years ago · Aug 06, 2018, 06:22 PM
1diff --git code/arbitrator.py code/arbitrator.py
2index a56cd43..071c913 100644
3--- code/arbitrator.py
4+++ code/arbitrator.py
5@@ -247,6 +247,7 @@
6
7 # Create connection to synced files DB.
8 self.dbcon = sqlite3.connect(SYNCED_FILES_DB)
9+ self.dbcon.text_factory = str
10 self.dbcur = self.dbcon.cursor()
11 self.dbcur.execute("CREATE TABLE IF NOT EXISTS synced_files(input_file text, transported_file_basename text, url text, server text)")
12 self.dbcur.execute("CREATE UNIQUE INDEX IF NOT EXISTS file_unique_per_server ON synced_files (input_file, server)")
13diff --git code/fsmonitor.py code/fsmonitor.py
14index 46a4bab..7e0a3c8 100644
15--- code/fsmonitor.py
16+++ code/fsmonitor.py
17@@ -147,6 +147,7 @@
18 # Database.
19 if self.dbcur is None:
20 self.dbcon = sqlite3.connect(self.dbfile)
21+ self.dbcon.text_factory = str
22 self.dbcur = self.dbcon.cursor()
23 # PathScanner.
24 if self.persistent == True and self.dbcur is not None:
25diff --git code/pathscanner.py code/pathscanner.py
26index 2c86f65..1660f47 100644
27--- code/pathscanner.py
28+++ code/pathscanner.py
29@@ -98,7 +98,6 @@
30
31 Returns False if there is already data available for this path.
32 """
33- path = path.decode('utf-8')
34
35 # Check if there really isn't any data available for this path.
36 self.dbcur.execute("SELECT COUNT(filename) FROM %s WHERE path=?" % (self.table), (path,))
37@@ -111,7 +110,6 @@
38
39 def purge_path(self, path):
40 """purge the metadata for a given path and all its subdirectories"""
41- path = path.decode('utf-8')
42
43 self.dbcur.execute("DELETE FROM %s WHERE path LIKE ?" % (self.table), (path + "%",))
44 self.dbcur.execute("VACUUM %s" % (self.table))
45@@ -179,7 +177,6 @@
46 - Can detect deleted directory trees.
47 """
48
49- path = path.decode('utf-8')
50 # Fetch the old metadata from the DB.
51 self.dbcur.execute("SELECT filename, mtime FROM %s WHERE path=?" % (self.table), (path, ))
52 old_files = {}
53@@ -221,7 +218,6 @@
54
55 def scan_tree(self, path):
56 """scan a directory tree for changes"""
57- path = path.decode('utf-8')
58
59 # Scan the current directory for changes.
60 result = self.scan(path)
61diff --git code/persistent_list.py code/persistent_list.py
62index 60a1d88..6840a07 100644
63--- code/persistent_list.py
64+++ code/persistent_list.py
65@@ -36,6 +36,7 @@
66 def __prepare_db(self, dbfile):
67 sqlite3.register_converter("pickle", cPickle.loads)
68 self.dbcon = sqlite3.connect(dbfile, detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
69+ self.dbcon.text_factory = str
70 self.dbcur = self.dbcon.cursor()
71 self.dbcur.execute("CREATE TABLE IF NOT EXISTS %s(id INTEGER PRIMARY KEY AUTOINCREMENT, item pickle)" % (self.table))
72 self.dbcon.commit()
73diff --git code/persistent_queue.py code/persistent_queue.py
74index 230688c..869072a 100644
75--- code/persistent_queue.py
76+++ code/persistent_queue.py
77@@ -42,6 +42,7 @@
78 def __prepare_db(self, dbfile):
79 sqlite3.register_converter("pickle", cPickle.loads)
80 self.dbcon = sqlite3.connect(dbfile, detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
81+ self.dbcon.text_factory = str
82 self.dbcur = self.dbcon.cursor()
83 self.dbcur.execute("CREATE TABLE IF NOT EXISTS %s(id INTEGER PRIMARY KEY AUTOINCREMENT, item pickle)" % (self.table))
84 self.dbcon.commit()
85@@ -121,6 +122,7 @@
86
87 def __prepare_db(self, dbfile):
88 self.dbcon = sqlite3.connect(dbfile)
89+ self.dbcon.text_factory = str
90 self.dbcur = self.dbcon.cursor()
91
92
93diff --git code/processors/link_updater.py code/processors/link_updater.py
94index fd57581..60b5b60 100644
95--- code/processors/link_updater.py
96+++ code/processors/link_updater.py
97@@ -54,6 +54,7 @@
98 # Step 3: verify that each of these files has been synced.
99 synced_files_db = urljoin(sys.path[0] + os.sep, SYNCED_FILES_DB)
100 self.dbcon = sqlite3.connect(synced_files_db)
101+ self.dbcon.text_factory = str
102 self.dbcur = self.dbcon.cursor()
103 all_synced = True
104 for urlstring in getUrls(sheet):
105diff --git code/verify.py code/verify.py
106index 8cbd2c1..8aaece2 100644
107--- code/verify.py
108+++ code/verify.py
109@@ -8,6 +8,7 @@
110 num_files_invalid = 0
111
112 dbcon = sqlite3.connect(SYNCED_FILES_DB)
113+dbcon.text_factory = str
114 dbcur = dbcon.cursor()
115 num_files = dbcur.execute("SELECT COUNT(*) FROM synced_files").fetchone()[0]
116 dbcur.execute("SELECT input_file, url, server FROM synced_files ORDER BY server")