projects
/
kiosk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of ssh://wwwjail.house/usr/local/git/base/kiosk
[kiosk.git]
/
file_writer.py
diff --git
a/file_writer.py
b/file_writer.py
index beac7bbcd284861e4b3d8bf7bb419c9bdd9a51b5..08be646da19addde1ece563932adef2e521f9043 100644
(file)
--- a/
file_writer.py
+++ b/
file_writer.py
@@
-1,10
+1,15
@@
#!/usr/bin/env python3
#!/usr/bin/env python3
+import logging
import os
from uuid import uuid4
import kiosk_constants
import os
from uuid import uuid4
import kiosk_constants
+
+logger = logging.getLogger(__name__)
+
+
class file_writer:
"""Helper context to write a pages file."""
class file_writer:
"""Helper context to write a pages file."""
@@
-15,6
+20,7
@@
class file_writer:
self.xforms = [file_writer.remove_tricky_unicode]
self.xforms.extend(transformations)
self.f = None
self.xforms = [file_writer.remove_tricky_unicode]
self.xforms.extend(transformations)
self.f = None
+ logger.info(f"Writing {self.temp_filename}...")
@staticmethod
def remove_tricky_unicode(x: str) -> str:
@staticmethod
def remove_tricky_unicode(x: str) -> str:
@@
-37,6
+43,7
@@
class file_writer:
def __exit__(self, exc_type, exc_value, exc_traceback):
self.close()
def __exit__(self, exc_type, exc_value, exc_traceback):
self.close()
+ logger.info(f"Copying {self.temp_filename} to {self.full_filename}")
cmd = f'/bin/mv -f {self.temp_filename} "{self.full_filename}"'
os.system(cmd)
print(cmd)
cmd = f'/bin/mv -f {self.temp_filename} "{self.full_filename}"'
os.system(cmd)
print(cmd)
@@
-49,8
+56,8
@@
class file_writer:
# Test
# Test
-#def toupper(x):
+#
def toupper(x):
# return x.upper()
# return x.upper()
-#with file_writer("test", transformations=[toupper]) as fw:
+#
with file_writer("test", transformations=[toupper]) as fw:
# fw.write(u"Another test!!")
# fw.write(u"Another test!!")