Permalink
Browse files

Added support for linux

  • Loading branch information...
1 parent f6c034d commit 8a1c9204f243e9335f315275bd0e7145bc3b733c @tech2077 tech2077 committed Jun 25, 2012
Showing with 27 additions and 6 deletions.
  1. +1 −1 README.md
  2. +26 −5 raspiwrite.py
View
2 README.md
@@ -5,7 +5,7 @@
## About
RasPiWrite is a simple and easily modifiable Python script that automates the process of mounting an SD card and downloading and installing a Linux image for a [Raspberry Pi](http://raspberrypi.org).
-Currently the script is only compatible with Mac OS X systems, mostly because Macs have no easy way of installing Raspberry Pi distros. The goal is to try to make the script universal for all UNIX-like systems over time.
+While this script has is fully functioning on Mac OS X, it now has at least working support for unix (Tested only on Ubuntu)
## Install
View
31 raspiwrite.py
@@ -53,6 +53,8 @@
end = "\033[0;0m"
WARNING = '\033[0;31m'
+OS = os.uname() #gets OS vars
+
def checkforUpdate():
print 'Checking for updates...'
global version
@@ -154,8 +156,12 @@ def matchSD(input): #grabs just the drive's name from the df -h command (macOSX
return match
def unmount(location): #unmounts the drive so that it can be rewrittern
+ global OS
print 'Unmounting the drive in preparation for writing...'
- output = getoutput('diskutil unmount ' + location)
+ if OS[0] != 'Darwin':
+ output = getoutput('umount ' + location)
+ else:
+ output = getoutput('diskutil unmount ' + location)
print output
if 'Unmount failed for' in output:
print WARNING + 'Error, the Following drive couldn\'t be unmounted, exiting...' + end
@@ -166,8 +172,9 @@ class transferInBackground (threading.Thread): #Runs the dd command in a thread
def run ( self ):
global SDsnip
global path
- copyString = 'dd bs=1m if=%s of=%s' % (path,SDsnip)
+ copyString = 'dd bs=1M if=%s of=%s' % (path,SDsnip)
print 'Running ' + copyString + '...'
+
print getoutput(copyString)
print 'done!'
@@ -234,6 +241,12 @@ def transfer(file,archiveType,obtain,SD,URL): #unzips the disk image
else:
print 'Image has already been unzipped'
path = finalPath
+
+ if OS[0] != 'Darwin':
+ print getoutput('pwd')
+ path = getoutput("pwd")+ "/" + file.split("/")[-1].replace(".zip", "") + "/" + file.split("/")[-1].replace(".zip", ".img")
+ print path
+ print "Not Darwin\n"
else:
print 'Ok... Unzipping the disk , this may take a while...'
print getoutput(extractCMD) #extract here!
@@ -245,8 +258,17 @@ def transfer(file,archiveType,obtain,SD,URL): #unzips the disk image
else:
print 'Image has already been unzipped'
path = finalPath
+
+ if OS[0] != 'Darwin':
+ print getoutput('pwd')
+ path = getoutput("pwd")+ "/" + file.split("/")[-1].replace(".zip", "") + "/" + file.split("/")[-1].replace(".zip", ".img")
+ print path
+ print "Not Darwin\n"
global SDsnip
- SDsnip = SD.replace(' ', '')[:-2]
+ if (SD.find("/dev/mmcblk") + 1):
+ SDsnip = "/dev/mmcblk" + SD[11]
+ else:
+ SDsnip = SD.replace(' ', '')[:-1]
print path
print '\n\n###################################################################'
print 'About to start the transfer procedure, here is your setup:'
@@ -401,10 +423,9 @@ def driveTest(SD):
////////////////////////
(Version 1.15 -MACOSX-)
"""
-OS = os.uname() #gets OS vars
if OS[0] != 'Darwin': #if Mac OS, will change to posix once I have worked around some of the command differences
print WARNING + 'I\'m sorry, but your OS isn\'t supported at this time, Linux/Unix users - please tune in soon for a POSIX version' + end
- exit()
+# exit()
if not os.geteuid()==0:
print WARNING + 'Please run the script using sudo e.g. sudo python raspiwrite.py, or sudo ./raspiwrite.py (need to chmod +x first)' + end
exit()

0 comments on commit 8a1c920

Please sign in to comment.