Created
June 10, 2013 10:25
-
-
Save cnh/5747770 to your computer and use it in GitHub Desktop.
This file contains 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
def login(): | |
import wx | |
from send_pass import send_pwd | |
class AP_App(wx.App): | |
def OnInit(self): | |
frame = AP_MainFrame ("Test application", (0, 0), (650, 350)) | |
# frame.Show() | |
self.SetTopWindow(frame) | |
loginPanel = AP_LoginPanel (frame) | |
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) | |
frame.Show() | |
return True | |
def OnCloseWindow (self, event): | |
self.Destroy() | |
class AP_MainFrame(wx.Frame): | |
def __init__(self, title, pos, size): | |
wx.Frame.__init__(self, None, -1, title, pos, size) | |
self.CreateStatusBar() | |
class AP_LoginPanel(wx.Panel): | |
def __init__(self, frame): | |
self.panel = wx.Panel(frame) | |
self.frame = frame | |
self.frame.SetStatusText("Authentification required!") | |
self.showLoginBox() | |
def showLoginBox (self): | |
# Create the sizer | |
sizer = wx.FlexGridSizer(rows=3, cols=2, hgap=5, vgap=15) | |
# Username | |
self.txt_Username = wx.TextCtrl(self.panel, 1, size=(150, -1)) | |
lbl_Username = wx.StaticText(self.panel, -1, "Username:") | |
sizer.Add(lbl_Username,0, wx.LEFT|wx.TOP| wx.RIGHT, 50) | |
sizer.Add(self.txt_Username,0, wx.TOP| wx.RIGHT, 50) | |
# Password | |
self.txt_Password = wx.TextCtrl(self.panel, 1, size=(150, -1), style=wx.TE_PASSWORD) | |
lbl_Password = wx.StaticText(self.panel, -1, "Password:") | |
sizer.Add(lbl_Password,0, wx.LEFT|wx.RIGHT, 50) | |
sizer.Add(self.txt_Password,0, wx.RIGHT, 50) | |
# Submit button | |
btn_Process = wx.Button(self.panel, -1, "&Login") | |
self.panel.Bind(wx.EVT_BUTTON, self.OnSubmit, btn_Process) | |
sizer.Add(btn_Process,0, wx.LEFT, 50) | |
self.panel.SetSizer(sizer) | |
def OnSubmit(self, event): | |
UserText = self.txt_Username.GetValue() | |
PasswordText = self.txt_Password.GetValue() | |
print UserText | |
print PasswordText | |
send_pwd(UserText,PasswordText) | |
if __name__ == '__main__': | |
app = AP_App() | |
app.MainLoop() | |
import string | |
from ctypes import windll | |
import time | |
import os | |
def get_drives(): | |
drives = [] | |
bitmask = windll.kernel32.GetLogicalDrives() | |
for letter in string.uppercase: | |
if bitmask & 1: | |
drives.append(letter) | |
bitmask >>= 1 | |
return drives | |
def read_id(drive): | |
f = open(drive, 'r') | |
return f.read() | |
def write_id(drive,s): | |
f = open(drive, 'a') | |
f.write(s) | |
f.close() | |
def usb_insert_event(): | |
before = set(get_drives()) | |
print "before usb drive insert is" + str(before) | |
pause = raw_input("Please insert the USB device, then press ENTER") | |
print ('Please wait...') | |
time.sleep(5) | |
after = set(get_drives()) | |
print "after usb drive insert is " + str(after) | |
drives = after - before | |
print "Delta is" + str(drives) | |
delta = len(drives) | |
if (delta): | |
for drive in drives: | |
if os.system("cd " + drive + ":") == 0: | |
newly_mounted = drive | |
print "There were %d drives added: %s. Newly mounted drive letter is %s" % (delta, drives, newly_mounted) | |
path =newly_mounted + ":/id.txt" | |
print "path is" + path | |
write_id(path,'test') | |
print read_id(path) | |
time.sleep(10) | |
else: | |
print "Sorry, I couldn't find any newly mounted drives." | |
print 'Press 1 for login' | |
print 'Press 2 to assign videos to locations' | |
print 'Press 3 to copy videos to usb' | |
user_input = raw_input("Enter your choice") | |
try: | |
number = int(user_input) | |
except ValueError: | |
print "that was no number: " + user_input | |
if number == 1: | |
login() | |
#app = AP_App() | |
#app.MainLoop() | |
elif number == 2: | |
print '2 pressed' | |
elif number == 3: | |
usb_insert_event() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment