def RunCommands(self, commands, master_template=[]): """Executes the command in the command field, or the commands using the master template.""" if not master_template: master_template = [''] for template in master_template: mapping = template.split(',') for temp_command in commands: command = temp_command.strip() if not command: continue for index in range(len(mapping)): command = command.replace('{%d}' % (index+1), mapping[index].strip()) # Replace {i} with the value from the template. # Command now contains the right variables. # Execute it. command_list = [entry for entry in shlex.split(command)] sys.stderr.write('[gasi] Executing: '+command) self.last_error = ''; engine = command_list[0].lower() # the only engine currently supported is 'gas' if engine=='gas': gas.execute(command_list[1:]) else: # They probably forgot the 'gas' in the syntax. # We will execute the command as if 'gas' were there. # However, this is open to change in the future, # to allow for the possibility of integrating GASI with # other libraries. gas.execute(command_list) sys.stderr.write('[gasi] Finished executing: '+command)
def RunCommands(self, commands, master_template=[]): """Executes the command in the command field, or the commands using the master template.""" if not master_template: master_template = [''] for template in master_template: mapping = template.split(',') for temp_command in commands: command = temp_command.strip() if not command: continue for index in range(len(mapping)): command = command.replace( '{%d}' % (index + 1), mapping[index].strip( )) # Replace {i} with the value from the template. # Command now contains the right variables. # Execute it. command_list = [entry for entry in shlex.split(command)] sys.stderr.write('[gasi] Executing: ' + command) self.last_error = '' engine = command_list[0].lower( ) # the only engine currently supported is 'gas' if engine == 'gas': gas.execute(command_list[1:]) else: # They probably forgot the 'gas' in the syntax. # We will execute the command as if 'gas' were there. # However, this is open to change in the future, # to allow for the possibility of integrating GASI with # other libraries. gas.execute(command_list) sys.stderr.write('[gasi] Finished executing: ' + command)
def LogOut(self, event): """Logs out and deletes the token file, if it exists.""" # Log out of GAS: gas.execute(['log_out']) # Reset the authentication frames self.log_in_frame.pack() self.log_out_frame.pack_forget()
def AutoLogIn(self): """Logs in to Google Apps based on the credentials given in the apps object, which is assumed to work successfully.""" gas.execute(['log_in']) # if we get here, then we've successfully logged in to gas email = gas.get_logged_in_user() self.log_out_label.configure(text='Currently signed in as %s' % email) self.log_in_frame.pack_forget() self.log_out_frame.pack()
def LogIn(self, event): """Logs in with the username and password supplied in the fields.""" fullUsername = self.log_in_username.get() password = self.log_in_password.get() try: username = fullUsername.split('@')[0] domain = fullUsername.split('@')[1] except: sys.stderr.write('Username must be of form: [email protected]') # log in to gas gas.execute(['log_in', 'email=%s' % fullUsername, 'password=%s' % password]) # if we get here, then we've successfully logged in to gas email = gas.get_logged_in_user() self.log_out_label.configure(text='Currently signed in as %s' % email) self.log_in_password.configure(text='') self.log_in_frame.pack_forget() self.log_out_frame.pack() sys.stderr.write('') # clears the status frame, in case there is anything there
def LogIn(self, event): """Logs in with the username and password supplied in the fields.""" fullUsername = self.log_in_username.get() password = self.log_in_password.get() try: username = fullUsername.split('@')[0] domain = fullUsername.split('@')[1] except: sys.stderr.write('Username must be of form: [email protected]') # log in to gas gas.execute( ['log_in', 'email=%s' % fullUsername, 'password=%s' % password]) # if we get here, then we've successfully logged in to gas email = gas.get_logged_in_user() self.log_out_label.configure(text='Currently signed in as %s' % email) self.log_in_password.configure(text='') self.log_in_frame.pack_forget() self.log_out_frame.pack() sys.stderr.write( '') # clears the status frame, in case there is anything there