Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNate Theis <natetheis@gmail.com>2010-12-01 19:16:36 (GMT)
committer Nate Theis <natetheis@gmail.com>2010-12-01 19:16:36 (GMT)
commit1a9fc4d1b399ad77a43696e3c597a0e9366aa7db (patch)
tree09ba837b50dd88664dcbc2d92e312ccb4dc28139
parent83fbe1520912a581e247dd143465f65cf5841c90 (diff)
Began USB stick support
-rw-r--r--burntools.py37
-rw-r--r--pexpect.pyobin28101 -> 30139 bytes
2 files changed, 29 insertions, 8 deletions
diff --git a/burntools.py b/burntools.py
index 9acd3bd..1bddbe7 100644
--- a/burntools.py
+++ b/burntools.py
@@ -1,6 +1,7 @@
# Copyright (c) 2010, Nathaniel Theis
-import pexpect, re
+import pexpect, re, fcntl, os, sys
+
#Define some handy things (regexes, strings, etc)
@@ -34,8 +35,26 @@ fixatedonematcher = re.compile(r"Fixating\stime:\s+(?P<time>\d+\.\d+)s")
carriagereturn = chr(13)
-
-
+class USBStickWriter():
+ def __init__(self, image, bs=512):
+ self.image = image
+ self.bs = bs
+
+ def run(self, device):
+ image_file = open(self.image, "r")
+ image_fd = image_file.fileno()
+
+ fcntl.fcntl(image_fd, fcntl.F_SETFL, os.O_NONBLOCK)
+ #We need to use non-blocking read, so tell Linux that
+
+ with open(device, "w") as out
+ while True:
+ block = image_file.read(self.bs)
+
+ if block == "": break
+
+ out.write(block)
+
class WodimWrapper():
'''WodimWrapper is a class to burn CDs with Wodim'''
def _get_track_data(self):
@@ -140,8 +159,10 @@ if __name__ == "__main__":
def printer(*args):
for arg in args: print arg
-
- ww = WodimWrapper([], printer, printer, printer,
- printer, printer, printer, printer,
- command_path="./wodim")
- ww.run()
+
+ f = USBStickWriter("ToasterActivity.py", bs=512)
+ f.run("/dev/mem")
+ #ww = WodimWrapper([], printer, printer, printer,
+ # printer, printer, printer, printer,
+ # command_path="./wodim")
+ #ww.run()
diff --git a/pexpect.pyo b/pexpect.pyo
index cbcce14..41a9d18 100644
--- a/pexpect.pyo
+++ b/pexpect.pyo
Binary files differ