Created
September 22, 2015 12:07
-
-
Save mdunschen/1eace6d86d85aa2873e8 to your computer and use it in GitHub Desktop.
Format RoadHawk helmet cam and add new date file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, time, os | |
from ctypes import * | |
def myFmtCallback(command, modifier, arg): | |
#print("command = ", command) | |
return 1 # TRUE | |
def format_drive(Drive, Format, Title): | |
fm = windll.LoadLibrary('fmifs.dll') | |
FMT_CB_FUNC = WINFUNCTYPE(c_int, c_int, c_int, c_void_p) | |
FMIFS_UNKNOWN = 0 | |
clustersize = c_int(32768) # 32K cluster size | |
fm.FormatEx(c_wchar_p(Drive), FMIFS_UNKNOWN, c_wchar_p(Format), | |
c_wchar_p(Title), True, clustersize, FMT_CB_FUNC(myFmtCallback)) | |
def adddatetime(ldrive): | |
f = open(os.path.join(ldrive, "time.txt"), "w") | |
s = "%s" % time.strftime("%Y %m %d %H %M %S", time.localtime()) | |
print s | |
f.write(s) | |
f.close() | |
if __name__ == "__main__": | |
# the drive letter | |
ldrive = sys.argv[1] | |
assert ldrive[0].lower() != 'c' | |
assert len(ldrive) == 2 and ldrive[-1] == ':' | |
# format | |
format_drive(ldrive, 'FAT32', 'NEW VOLUME') | |
# need to add a few directories, so that setting the time will have an effect | |
os.makedirs(os.path.join(ldrive, "DCIM", "100MEDIA")) | |
# add date and time | |
adddatetime(ldrive) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment