Beispiel #1
0
    def git_push(args):
        parser = argparse.ArgumentParser(prog='git push'
                                         , usage='git push [http(s)://<remote repo>] [-u username[:password]]'
                                         , description="Push to a remote repository")
        parser.add_argument('url', type=str, nargs='?', help='URL to push to')
        parser.add_argument('-u', metavar='username[:password]', type=str, required=False, help='username[:password]')
        result = parser.parse_args(args)

        user, sep, pw = result.u.partition(':') if result.u else (None,None,None)

        repo = _get_repo()
        
        #Try to get the remote origin
        if not result.url:
            result.url = repo.remotes.get('origin','')

        branch_name = os.path.join('refs','heads', repo.active_branch)  #'refs/heads/%s' % repo.active_branch

        print "Attempting to push to: {0}, branch: {1}".format(result.url, branch_name)

        netloc = urlparse.urlparse(result.url).netloc

        keychainservice = 'shellista.git.{0}'.format(netloc)

        if sep and not user:
            # -u : clears keychain for this server
            for service in keychain.get_services():
                if service[0]==keychainservice:
                    keychain.delete_password(*service)

        #Attempt to retrieve user
        if not user and SAVE_PASSWORDS:
            try:
                user = dict(keychain.get_services())[keychainservice]
            except KeyError:
                user, pw = console.login_alert('Enter credentials for {0}'.format(netloc))

        if user:
            if not pw and SAVE_PASSWORDS:
                pw = keychain.get_password(keychainservice, user)

            #Check again, did we retrieve a password?
            if not pw:
                user, pw = console.login_alert('Enter credentials for {0}'.format(netloc), login=user)
                #pw = getpass.getpass('Enter password for {0}: '.format(user))

            opener = auth_urllib2_opener(None, result.url, user, pw)

            print porcelain.push(repo.repo, result.url, branch_name, opener=opener)
            keychain.set_password(keychainservice, user, pw)

        else:
            print porcelain.push(repo.repo, result.url, branch_name)
Beispiel #2
0
def get_token():
	token = keychain.get_password('gistcheck','gistcheck')
	if token is None:
		u, p = console.login_alert('GitHub Login')
		token = auth(u, p)['token']
		keychain.set_password('gistcheck','gistcheck',token)
	return token
	def login_protocol(self):
		speech.say('Please log into your Jarvis Account to utilize my services', 'en-EN', 0.5)
		self.login_personel = console.login_alert('Please log into your Jarvis Account to utilize services')
		self.login_personel_array = []
		for i in self.login_personel:
			self.login_personel_array.append(i)
		self.name_of_current_subject_array = []
		self.name = self.login_personel_array[0]
		try:
			self.read_from_personal_file = open(self.name.upper(), 'r')
			if self.read_from_personal_file.mode == 'r':
				self.read_from_file = self.read_from_personal_file.read()
				# https://stackoverflow.com/questions/3277503/how-do-i-read-a-file-line-by-line-into-a-list
				self.name_of_current_subject_array.append(self.read_from_file)
				for i in self.name_of_current_subject_array:
					if i.rfind(self.name.upper()):
						speech.say('Welcome back ' + self.name + '!', 'en-EN', 0.5)
						speech.say('How may I be of service?', 'en-EN', 0.5)
						print 'Welcome back ' + self.name + '!'
						print 'How may I be of service?'
						self.idle()
						self.read_from_personal_file.close()
					else:
						speech.say('Pleasure to meet you ' + self.name, 'en-EN', 0.5)
						print 'Pleasure to meet you ' + self.name + '!'
						self.your_own_personal_file_write()
		except:
			speech.say('Pleasure to meet you ' + self.name, 'en-EN', 0.5)
			print 'Pleasure to meet you ' + self.name + '!'
			self.your_own_personal_file_write()
			self.getting_to_know_you()
Beispiel #4
0
def get_token():
    token = keychain.get_password('gistcheck', 'gistcheck')
    if token is None:
        u, p = console.login_alert('GitHub Login')
        token = auth(u, p)['token']
        keychain.set_password('gistcheck', 'gistcheck', token)
    return token
Beispiel #5
0
def login():
    global email_user, email_pwd
    info = console.login_alert('title', 'Enter your login credentials')
    if info == None:
        console.hud_alert('Login Cancelled', 'error', 1.5)
    else:
        email_user = info[0]
        email_pwd = info[1]
        setup()
def login():
    global email_user, email_pwd
    info = console.login_alert('title', 'Enter your login credentials')
    if info == None:
        console.hud_alert('Login Cancelled', 'error', 1.5)
    else:
        email_user = info[0]
        email_pwd = info[1]
        setup()
Beispiel #7
0
 def get_services(self, blob=None):
     if blob and os.path.isfile(blob):
         import lastpass
         email = keychain.get_password('lastpass_email', 'lastpass')
         password = keychain.get_password('lastpass_master', 'lastpass') or ''
         email, password = console.login_alert('LastPass login', '', email, password)
         vault = lastpass.Vault.open_local(blob, email, password)
         return [(x.name, x.username, x.password) for x in vault.accounts]
     else:
         return keychain.get_services()
Beispiel #8
0
    def __init__(self, db):
        if db is None:
            raise RuntimeError('empty db')

        # retrieve user id and pass
        try:
            self.userID = db['userID']
            self.userPass = db['userPass']

        except:
            pass

        if self.userID == '' or self.userPass == '':
            while self.userID == '' or self.userPass == '':
                self.userID, self.userPass = console.login_alert('BMWGROUP ID/Password', 'Please input your ID/Password.')

            db['userID'] = self.userID
            db['userPass'] = self.userPass

            db.sync()

        # retrive access token
        try:
            self.bearerToken = db['accessToken']
            self.expires = db['accessTokenExpires']

            # check expires
            if self.expires - int(time.time()) < 0:
                # expired, reset access token
                self.bearerToken = ''

        except:
            pass

        if self.bearerToken == '' or self.expires == 0:
            self.__authenticate()

            db['accessToken'] = self.bearerToken
            db['accessTokenExpires'] = self.expires

            db.sync()

        # retrieve vin
        try:
            self.vin = db['vin']
        except:
            pass

        if self.vin == '':
            self.get_vin()

            db['vin'] = self.vin
            db.sync()

        return
Beispiel #9
0
def login():
	username, password = load_credentials()

	try:
		username, password = console.login_alert('Github Login', '', username, password, 'Login')
	except KeyboardInterrupt:
		return None

	save_credentials(username, password)

	return Github(username, password).get_user()
Beispiel #10
0
 def reset_account(self, sender):
     try:
         username, password = console.login_alert('请输入账号密码')
     except KeyboardInterrupt:
         pass
     else:
         text = json.dumps(dict(username=username, password=password),
                           indent=2)
         with open(ACCOUNT_FILE, 'w') as f:
             f.write(text)
         console.hud_alert('完成')
Beispiel #11
0
def get_credentials(svc):

    f = filter(lambda x: x[0] == svc, keychain.get_services())

    res = [x for x in f]

    if not res:

        usr, pwd = console.login_alert(svc)
        keychain.set_password(svc, usr, pwd)

        return usr, pwd

    return (res[0][1], keychain.get_password(*res[0]))
Beispiel #12
0
def commit():
	gist = get_gist_id(editor.get_path())
	if gist is not None:
		token = keychain.get_password('gistcheck','gistcheck')
		if token is None:
			u, p = console.login_alert('GitHub Login')
			r = json.loads(auth(u, p))
			print r
			token = r['token']
			keychain.set_password('gistcheck','gistcheck',token)
		fname = os.path.basename(editor.get_path())
		m = console.input_alert('Edit Description','Enter a new description:','')
		if m == '': m = None
		return edit(gist,{fname:editor.get_text()},token,m)
Beispiel #13
0
def settings(sender):
    res_url = console.input_alert('Server url:port','http://www.somethings.com:8000')
    res = console.login_alert('Host Info','User and password','user','password')
    if res_url and res:
        global url
        global user
        global passwd
        with open('settings.conf','w') as f:
            f.write('[settings]\n')
            f.write('host=%s\n' % res_url)
            url = res_url+link
            passwd = hashlib.md5(res[1]).hexdigest()
            user = res[0]
            f.write('user=%s\n' % user)
            f.write('passwd=%s\n' % passwd)
Beispiel #14
0
 def get_account_password(self, sender):
     try:
         username, password = console.login_alert('请输入账号密码')
     except KeyboardInterrupt:
         self.close()
     if username and password:
         renew_account(username, password)
         renew()
         init_config()
         create_db()
         get_favcat()
         import conf.global_variables as glv
         glv.init()
         self.present_listview()
         self.close()
Beispiel #15
0
def login():
	login = console.login_alert('Please sign in')
	
	if login[0] in logins:
		loginConfirm = True
	else:
		loginConfirm = False 
	if login[1] in passwords:
		passwordConfirm = True
	else:
		passwordConfirm = False 
		
	if loginConfirm == True and passwordConfirm == True:
		console.alert('Welcome!')
	else:
		console.alert('Access denied')
Beispiel #16
0
def welcome():
    if not is_suitable_device():
        console.hud_alert(ipadpro_iphone_warning, 'error')
    t = dialogs.list_dialog(title="最符合你状况的描述是:",
                            items=choices_list,
                            multiple=False)
    if t == choices_list[0]:
        console.alert(manual[0])
    elif t == choices_list[1]:
        console.alert(manual[1])
    elif t == choices_list[2]:
        console.alert(manual[2])
    elif t == choices_list[3]:
        username, password = console.login_alert('请输入账号密码')
        if username and password:
            renew_account(username, password)
            renew()
            init_config()
            create_db()
Beispiel #17
0
def get_login():
    # Get login data from the keychain, if it has been saved already:
    login_data_json = keychain.get_password('iTunesConnect', 'Default')
    if login_data_json is None:
        # Show input dialogs for vendor id and user/password:
        vendor_id = console.input_alert('Vendor ID (8xxxxxxx)')
        user, password = console.login_alert('iTunes Connect Login')
        if user and password and vendor_id:
            # Save login data to keychain as json string:
            login_data = {
                'user': user,
                'password': password,
                'vendor_id': vendor_id
            }
            keychain.set_password('iTunesConnect', 'Default',
                                  json.dumps(login_data))
    else:
        login_data = json.loads(login_data_json)
        user = login_data['user']
        password = login_data['password']
        vendor_id = login_data['vendor_id']
    return user, password, vendor_id
Beispiel #18
0
#coding: utf-8

import console
import keychain
import pickle

login = keychain.get_password('pinboard.in', 'pythonista')
if login is not None:
    user, pw = pickle.loads(login)
else:
    user, pw = console.login_alert('Pinboard Login', '')
    login = pickle.dumps((user, pw))
    keychain.set_password('pinboard.in', 'pythonista', login)

import requests
import json
pinboard_url = 'https://api.pinboard.in/v1/tags/get?format=json'
r = requests.get(pinboard_url, auth=(user, pw))
data = json.loads(r.text)
tags = data.items()

# minTags is the minimum amount of times this tag must link to a bookmark to be part of our final list.
# Change the value to 1 to grab all tags, for example.
minTags = 10
# This will generate a list without tags with less than minTags bookmarks.
filteredTags = [(str(k).lower(), int(v)) for k, v in tags if int(v) >= minTags]
# Change to True to sort your tags by name, otherwise they'll be sorted by count
sortByName = False

from operator import itemgetter
Beispiel #19
0
def git_push(args):
    parser = argparse.ArgumentParser(
        prog='git push',
        usage=
        'git push [http(s)://<remote repo> or remote] [-u username[:password]]',
        description="Push to a remote repository")
    parser.add_argument('url', type=str, nargs='?', help='URL to push to')
    parser.add_argument('-u',
                        metavar='username[:password]',
                        type=str,
                        required=False,
                        help='username[:password]')
    result = parser.parse_args(args)

    user, sep, pw = result.u.partition(':') if result.u else (None, None, None)

    repo = _get_repo()

    origin = 'origin'
    if not result.url:
        result.url = repo.remotes.get('origin', '')
    if result.url in repo.remotes:
        origin = result.url
        result.url = repo.remotes.get(origin)

    branch_name = os.path.join(
        'refs', 'heads',
        repo.active_branch)  #'refs/heads/%s' % repo.active_branch

    print("Attempting to push to: {0}, branch: {1}".format(
        result.url, branch_name))

    netloc = urlparse.urlparse(result.url).netloc

    keychainservice = 'stash.git.{0}'.format(netloc)

    if sep and not user:
        # -u : clears keychain for this server
        for service in keychain.get_services():
            if service[0] == keychainservice:
                keychain.delete_password(*service)

    #Attempt to retrieve user
    if not user and SAVE_PASSWORDS and result.url.startswith('http'):
        try:
            user = dict(keychain.get_services())[keychainservice]
        except KeyError:
            user = input('Enter username: '******'Enter password: '******'Enter credentials for {0}'.format(netloc))

    outstream = StringIO()
    if user:
        if not pw and SAVE_PASSWORDS:
            pw = keychain.get_password(keychainservice, user)

        #Check again, did we retrieve a password?
        if not pw:
            user, pw = console.login_alert(
                'Enter credentials for {0}'.format(netloc), login=user)
        host_with_auth = '{}:{}@{}'.format(user, pw, netloc)
        url = urlparse.urlunparse(
            urlparse.urlparse(result.url)._replace(netloc=host_with_auth))
        porcelain.push(repo.repo.path, url, branch_name, errstream=outstream)
        keychain.set_password(keychainservice, user, pw)

    else:
        porcelain.push(repo.repo.path,
                       result.url,
                       branch_name,
                       errstream=outstream)

    for line in outstream.getvalue().split('\n'):
        print((line.replace(pw, '*******') if pw else line))

    print('success!')
Beispiel #20
0
# https://gist.github.com/omz/9cc60b13658b565b34cc

# Very simple SSH client for Pythonista
import paramiko
import console

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
host = console.input_alert('Connect to')
user, passwd = console.login_alert('Login')
ssh.connect(host, username=user, password=passwd)
print 'Connected to %s. Type `exit` to disconnect.' % host
while True:
	cmd = raw_input()
	if cmd == 'exit':
		break
	stdin, stdout, stderr = ssh.exec_command(cmd)
	print stdout.read()
ssh.close()
print 'Disconnected.'
Beispiel #21
0
shell('git checkout gh-pages')
if not os.path.exists('_posts'):
    console.hide_activity()
    console.show_activity('Creating posts directory...')
    shell('mkdir _posts')
shell('cd _posts')
console.hide_activity()
console.show_activity('Writing data to file...')
now = datetime.datetime.now()
file_name = str(now.year) + '-' + str(now.month) + '-' + str(
    now.day) + '-' + sys.argv[1]
file_obj = open(file_name, 'w')
file_obj.write(sys.argv[2])
file_obj.close()
console.hide_activity()
console.show_activity('Staging files...')
shell('cd ..')
shell('git add "_posts/' + file_name + '"')
console.hide_activity()
name = console.input_alert('Enter name to commit as')
email = console.input_alert('Enter email to commit as')
console.show_activity('Committing to gh-pages...')
shell('git commit "Post ' + sys.argv[1] + ' to blog" ' + name + ' "' + email +
      '"')
console.hide_activity()
username, password = console.login_alert(
    'Sign in to GitHub', 'Your credentials will NOT be saved.')
console.show_activity('Pushing to GitHub...')
shell('git push -u ' + username + ':' + password)
console.hide_activity()
console.hud_alert('Post successful!', 'success')
Beispiel #22
0
import StringIO
import keychain
import pickle
import cgi
import sys




# Uncomment this line to reset stored password
# keychain.delete_password('vaughanje', 'editorial')
login = keychain.get_password('vaughanje', 'editorial')
if login is not None:
	user, pw = pickle.loads(login)
else:
	user, pw = console.login_alert('FTPS Login Needed', 'No login credentials found.')
	pickle_token = pickle.dumps((user, pw))
	keychain.set_password('vaughanje', 'editorial', pickle_token)


# 

remotePath = "/public_html/blog/source/"
host = "crawlab.org"
port = 21


docTitle = console.input_alert("Filename", "Enter File Name")
fileName = docTitle+'.md'
confirmation = console.alert('Confirm', 'Go ahead and post?','Yes','No')
# Use with caution -- This saves the LastPass vault in the iOS keychain.
# Although the keychain is encrypted, I believe it is not 100% secure.
# At a minimum you probably should `keychain.set_master_password()`

import clipboard, console, keychain, lastpass, uuid, webbrowser

email = keychain.get_password('lastpass_email', 'lastpass') or ''
password = keychain.get_password('lastpass_master', 'lastpass') or ''
email, password = console.login_alert('LastPass login', '', email, password)
device = keychain.get_password('lastpass_uuid', 'lastpass')

try:
	blob = lastpass.Vault.fetch_blob(email, password, None, device)
except lastpass.LastPassIncorrectGoogleAuthenticatorCodeError as e:
	googleauth = None
	if not device:
		console.hud_alert(message='You will now be redirected to Google Authenticator',duration=1)
		webbrowser.open('otpauth:')
		console.hud_alert(message='Enter the 2FA code',duration=5.0)
		googleauth = console.input_alert('GoogleAuth', '', clipboard.get())
		trusted = console.alert('Trusted', 'Save this device as trusted?', 'Save', 'Don\'t Save', hide_cancel_button=True)
		if not trusted:
			device = str(uuid.uuid1())
			keychain.set_password('lastpass_uuid', 'lastpass', device)
	blob = lastpass.Vault.fetch_blob(email, password, googleauth, device)

save_vault = console.alert("Save to keychain", "Would you like to save your vault to the keychain?", "Don't Save", "Save", hide_cancel_button=True)
if not save_vault:
	save_blob = console.alert("Save blob local", "Would you like to save the encrypted blob locally?", "Don't Save", "Save", hide_cancel_button=True)
	if save_blob:
		import pickle, os
Beispiel #24
0
shell('git pull')
console.hide_activity()
console.show_activity('Switching to gh-pages...')
shell('git checkout gh-pages')
if not os.path.exists(posts_dir):
  console.hide_activity()
  console.show_activity('Creating posts directory...')
  shell('mkdir {}'.format(posts_dir))
shell('cd {}'.format(posts_dir))
console.hide_activity()
console.show_activity('Writing data to file...')
now = datetime.datetime.now()
file_name = '{}-{}-{}-{}'.format(now.year, now.month, now.day, post_name)
with open(file_name, 'w') as file_obj:
    file_obj.write(post_content)
console.hide_activity()
console.show_activity('Staging files...')
shell('cd ..')
shell('git add "{}/{}"'.format(posts_dir, file_name))
console.hide_activity()
name = console.input_alert('Enter name to commit as')  # unclear.  is it the git username, forum username, postname, other?
email = console.input_alert('Enter email to commit as')  # if git username then why not just use username below instead
console.show_activity('Committing to gh-pages...')
shell('git commit "Post {} to blog" {} "{}"'.format(post_name, name, email))  # why leave name out of double quotes?
console.hide_activity()
username, password = console.login_alert('Sign in to GitHub', 'Your credentials will NOT be saved.')
console.show_activity('Pushing to GitHub...')
shell('git push -u {}:{}'.format(username, password))
password = None
console.hide_activity()
console.hud_alert('Post successful!', 'success')
# Use with caution -- This saves the LastPass vault in the iOS keychain.
# Although the keychain is encrypted, I believe it is not 100% secure.
# At a minimum you probably should `keychain.set_master_password()`

import clipboard, console, keychain, lastpass, uuid, webbrowser

email = keychain.get_password('lastpass_email', 'lastpass') or ''
password = keychain.get_password('lastpass_master', 'lastpass') or ''
email, password = console.login_alert('LastPass login', '', email, password)
device = keychain.get_password('lastpass_uuid', 'lastpass')

try:
    blob = lastpass.Vault.fetch_blob(email, password, None, device)
except lastpass.LastPassIncorrectGoogleAuthenticatorCodeError as e:
    googleauth = None
    if not device:
        console.hud_alert(
            message='You will now be redirected to Google Authenticator',
            duration=1)
        webbrowser.open('otpauth:')
        console.hud_alert(message='Enter the 2FA code', duration=5.0)
        googleauth = console.input_alert('GoogleAuth', '', clipboard.get())
        trusted = console.alert('Trusted',
                                'Save this device as trusted?',
                                'Save',
                                'Don\'t Save',
                                hide_cancel_button=True)
        if not trusted:
            device = str(uuid.uuid1())
            keychain.set_password('lastpass_uuid', 'lastpass', device)
    blob = lastpass.Vault.fetch_blob(email, password, googleauth, device)
Beispiel #26
0
        content = sys.argv[argument_index]
        argument_index += 1
    except IndexError:
        content = clipboard.get()

    # Gists created are private by default
    try:
        public = sys.argv[public_index] == "public"
    except:
        public = False

# Check if the user has already authenticated
access_token = keychain.get_password("GitHub", username)
if access_token is None:
    try:
        username, password = console.login_alert("GitHub Login")
    except KeyboardInterrupt:
        pass
    else:
        data = json.dumps({"scopes": ["gist"], "note": "Pythonista"})
        console.show_activity()
        response = requests.post("https://api.github.com/authorizations",
                                 data=data,
                                 auth=(username, password))
        console.hide_activity()
        if response.status_code == 201:
            access_token = response.json['token']
            keychain.set_password("GitHub", username, access_token)
        else:
            console.alert("Invalid credentials. Exiting.")
            sys.exit(0)
Beispiel #27
0
def git_push(args):
    parser = argparse.ArgumentParser(prog='git push'
                                     , usage='git push [http(s)://<remote repo> or remote] [-u username[:password]]'
                                     , description="Push to a remote repository")
    parser.add_argument('url', type=str, nargs='?', help='URL to push to')
    parser.add_argument('-u', metavar='username[:password]', type=str, required=False, help='username[:password]')
    result = parser.parse_args(args)

    user, sep, pw = result.u.partition(':') if result.u else (None,None,None)

    repo = _get_repo()

    origin='origin'
    if not result.url:
        result.url = repo.remotes.get('origin','')
    if result.url in repo.remotes:
        origin=result.url
        result.url=repo.remotes.get(origin)

    branch_name = os.path.join('refs','heads', repo.active_branch)  #'refs/heads/%s' % repo.active_branch

    print("Attempting to push to: {0}, branch: {1}".format(result.url, branch_name))

    netloc = urlparse.urlparse(result.url).netloc

    keychainservice = 'stash.git.{0}'.format(netloc)

    if sep and not user:
        # -u : clears keychain for this server
        for service in keychain.get_services():
            if service[0]==keychainservice:
                keychain.delete_password(*service)

    #Attempt to retrieve user
    if not user and SAVE_PASSWORDS and result.url.startswith('http'):
        try:
            user = dict(keychain.get_services())[keychainservice]
        except KeyError:
            user = input('Enter username: '******'Enter password: '******'Enter credentials for {0}'.format(netloc))

    outstream = StringIO()
    if user:
        if not pw and SAVE_PASSWORDS:
            pw = keychain.get_password(keychainservice, user)

        #Check again, did we retrieve a password?
        if not pw:
            user, pw = console.login_alert('Enter credentials for {0}'.format(netloc), login=user)
        host_with_auth='{}:{}@{}'.format(user,pw,netloc)
        url=urlparse.urlunparse(
            urlparse.urlparse(result.url)._replace(
                netloc=host_with_auth))
        porcelain.push(repo.repo.path, url, branch_name, errstream=outstream)
        keychain.set_password(keychainservice, user, pw)

    else:
        porcelain.push(repo.repo.path, result.url, branch_name, errstream=outstream)
 
    for line in outstream.getvalue().split('\n'):
        print((line.replace(pw, '*******') if pw else line))
    
    print('success!')
import console
import smtplib
import time
import ui

email_provider = raw_input('Gmail, AOL, Yahoo! or Comcast? ').title()
login = (console.login_alert('Login', 'Enter your login credentials.', '', '',
                             'Submit'))
email_user = login[0]
email_pwd = login[1]


def send_action(sender):
    global sendto, subj, assignment
    sendto = v['tofield'].text
    subj = v['subjectfield'].text
    assignment = v['message'].text
    main()


def cancel_action(sender):
    smtpserver.close()
    ui.close_all()


def main():
    global sendto, subj, assignment
    header = 'To: ' + sendto + '\n' + 'From: ' + email_user + '\n' + 'Subject: ' + subj + '\n'
    msg = header + assignment + '\n'
    smtpserver.sendmail(email_user, sendto, msg)
    sent_time = time.strftime("%A, %B %d, %Y at %I:%M:%S %p.",
import console
import smtplib
import time
import ui

email_provider = raw_input('Gmail, AOL, Yahoo! or Comcast? ').title() 
login = (console.login_alert('Login', 'Enter your login credentials.', '', '', 'Submit'))
email_user = login[0]
email_pwd = login[1]

def send_action(sender):
	global sendto, subj, assignment
	sendto = v['tofield'].text
	subj = v['subjectfield'].text	
	assignment = v['message'].text
	main()
	
def cancel_action(sender):
	smtpserver.close()
	ui.close_all()

def main():	
	global sendto, subj, assignment		
	header = 'To: ' + sendto + '\n' + 'From: ' + email_user + '\n' + 'Subject: ' + subj +'\n'
	msg = header + assignment + '\n'
	smtpserver.sendmail(email_user, sendto, msg)
	sent_time = time.strftime("%A, %B %d, %Y at %I:%M:%S %p.", time.localtime())
	console.hud_alert('Your message has been sent successfully on ' + sent_time, 'success', 2.1)
	v['tofield'].text = ''
	v['subjectfield'].text = ''
	v['message'].text = ''