Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions raspiwrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
# .kkx0NXk'...dNNxldK'
# 'k...0o....,O...d:
# ;o;'oM0olkWc.;oc
# .cOx....dOl.
# .x00k.
# .cOx....dOl.
# .x00k.

#////////////////////////////
# * Raspberry Pi SD Writer
Expand All @@ -22,17 +22,17 @@
# Copyright Matthew Jump 2012
# The following code is licenced under the Gnu Public Licence, please see gpl.txt for reference
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# VERSION 1.15 -MACOSX- (June 2012) BETA
# * Fix to unzipping system - credit to alecthegeek
Expand Down Expand Up @@ -84,8 +84,8 @@ def checkforUpdate():
'''

except urllib2.URLError, e:
print """There was an error in checking for an update: %r
""" % e
print """There was an error in checking for an update: %r
""" % e


def grabRoot(distro): #Parses the raspberry pi downloads page for the links for the currently RasPiWrite supported distros
Expand All @@ -103,8 +103,8 @@ def getZipUrl(url): #gets all the urls that end in .zip or .tar.bz2 (only two di
htmlSource = urllib2.urlopen(url).read()
linksList = re.findall('<a href="?([^\s^"]+)',htmlSource)
for link in linksList:
if link.endswith('.zip') or link.endswith('.tar.bz2'):
links.append(link)
if link.endswith('.zip') or link.endswith('.tar.bz2'):
links.append(link)
return links

def findDL(OS): #legacy reasons (Rasberry Pi website doesn't currently list Fedora - http://www.raspberrypi.org/phpBB3/viewtopic.php?f=2&t=5624)
Expand All @@ -129,14 +129,14 @@ def download(url): #http://stackoverflow.com/questions/22676/how-do-i-download-
file_size_dl = 0
block_sz = 8192
while True:
buffer = u.read(block_sz)
if not buffer:
break
file_size_dl += len(buffer)
f.write(buffer)
status = r"%10d [%3.2f%%]" % (file_size_dl, file_size_dl * 100. / file_size)
status = status + chr(8)*(len(status)+1)
print status,
buffer = u.read(block_sz)
if not buffer:
break
file_size_dl += len(buffer)
f.write(buffer)
status = r"%10d [%3.2f%%]" % (file_size_dl, file_size_dl * 100. / file_size)
status = status + chr(8)*(len(status)+1)
print status,
f.close()

def cleanOutput(text2): #cleans up the output from df -h
Expand Down Expand Up @@ -174,13 +174,13 @@ def run ( self ):
global path
if OS[0] != 'Darwin':
copyString = 'dd bs=1M if=%s of=%s' % (path,SDsnip)
else
else:
copyString = 'dd bs=1m if=%s of=%s' % (path,SDsnip)
print 'Running ' + copyString + '...'

print getoutput(copyString)
print 'done!'

def transfer(file,archiveType,obtain,SD,URL): #unzips the disk image
global path
Expand Down Expand Up @@ -272,10 +272,10 @@ def transfer(file,archiveType,obtain,SD,URL): #unzips the disk image
SDsnip = "/dev/mmcblk" + SD[11]
else:
if OS[0] != 'Darwin':
SDsnip = SD.replace(' ', '')[:-1]
SDsnip = SD.replace(' ', '')[:-1]
else:
# remove weird partition notation in OS X partition names
SDsnip = SD.replace(' ', '')[:-2]
SDsnip = SD.replace(' ', '')[:-2]

print path
print '\n\n###################################################################'
Expand Down Expand Up @@ -387,7 +387,7 @@ def getImage(SD): #gives the user a bunch of options to download an image, or se
if matchBzip is not None:
print 'found Bz2'
transfer(userLocate, 'bz2', 'usr',SD,'none')

else:
print 'sorry, the file you have specified doesn\'t exist, please try again'
Expand Down Expand Up @@ -421,8 +421,8 @@ def driveTest(SD):
.kkx0NXk'...dNNxldK'
'k...0o....,O...d:
;o;'oM0olkWc.;oc
.cOx....dOl.
.x00k.
.cOx....dOl.
.x00k.
""" + end
print """//////////////////////// """ + boldStart + """
* Raspberry Pi SD Writer """ + end + """
Expand Down