mount.py
489 Bytes
import uuid
import os
from runcmd import runProcess
def mount(device):
mountID = str(uuid.uuid4())
os.mkdir("/mnt/" + mountID)
output, code = runProcess(["mount","-o","ro",device,"/mnt/" + mountID])
if code != 0:
raise Exception("Unable to mount " + device)
return mountID
def umount(mountID):
output, code = runProcess(["umount","/mnt/" + mountID])
if code != 0:
raise Exception("Unable to umount " + mountID)
os.rmdir("/mnt/" + mountID)