Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: andrewn/raspi-printer
base: 54cd2ff9b5
...
head fork: andrewn/raspi-printer
compare: 52da786190
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 12 additions and 5 deletions.
  1. +12 −5 printer.py
View
17 printer.py
@@ -48,17 +48,23 @@ def checkForDownload():
print "Checking for download: " + url
response = urllib2.urlopen(req)
+
+ content_length = int(response.info()['Content-length'])
+
+ print "Content length: " + str(content_length)
+
status = str( response.getcode() )
print "Status: " + status
- if status == '200':
+ if status == '200' and content_length > 0:
print "has response"
sendToPrinter(response)
+ elif content_length == 0:
+ print "content length was 0"
else:
print "got response: " + status
- time.sleep(5)
-
+
def sendToPrinter(f):
print "Printing."
bytes = f.read()
@@ -72,5 +78,6 @@ def sendToPrinter(f):
print printerId
print printerDevice
-#while(True):
-checkForDownload()
+while(True):
+ checkForDownload()
+ time.sleep(5)

No commit comments for this range

Something went wrong with that request. Please try again.