Python builtins.input() Examples
The following are 30
code examples of builtins.input().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
builtins
, or try the search function
.
Example #1
Source File: usergroup.py From passhport with GNU Affero General Public License v3.0 | 6 votes |
def prompt_edit(req): """Prompt usergroup to obtain data to request""" name = input("Name of the usergroup you want to modify: ") if req.show("usergroup", {"<name>": name}) == 0: new_name = input("New name: ") new_comment = input("New comment: ") if len(new_comment.strip()) == 0: answer = input("Remove original comment? [y/N]") if answer == "y": new_comment = "PASSHPORTREMOVECOMMENT" return {"<name>": name, "--newname": new_name, "--newcomment": new_comment} return None
Example #2
Source File: nsidc_icesat2_associated.py From read-ICESat-2 with MIT License | 6 votes |
def http_pull_file(remote_file,remote_mtime,local_file,MODE): #-- Printing files transferred print('{0} -->\n\t{1}\n'.format(remote_file,local_file)) #-- Create and submit request. There are a wide range of exceptions #-- that can be thrown here, including HTTPError and URLError. request = urllib2.Request(remote_file) response = urllib2.urlopen(request) #-- chunked transfer encoding size CHUNK = 16 * 1024 #-- copy contents to local file using chunked transfer encoding #-- transfer should work properly with ascii and binary data formats with open(local_file, 'wb') as f: shutil.copyfileobj(response, f, CHUNK) #-- keep remote modification time of file and local access time os.utime(local_file, (os.stat(local_file).st_atime, remote_mtime)) os.chmod(local_file, MODE) #-- PURPOSE: help module to describe the optional input parameters
Example #3
Source File: decompile.py From dcc with Apache License 2.0 | 6 votes |
def get_class(self, class_name): """ Return the :class:`DvClass` with the given name The name is partially matched against the known class names and the first result is returned. For example, the input `foobar` will match on Lfoobar/bla/foo; :param str class_name: :return: the class matching on the name :rtype: DvClass """ for name, klass in self.classes.items(): # TODO why use the name partially? if class_name in name: if isinstance(klass, DvClass): return klass dvclass = self.classes[name] = DvClass(klass, self.vma) return dvclass
Example #4
Source File: token_provider.py From Paradrop with Apache License 2.0 | 6 votes |
def get_token(self): url_parts = urlparse(self.auth_url) print("Attempting to log in to authentication domain {}".format(url_parts.netloc)) self.username = builtins.input("Username: ") password = getpass.getpass("Password: ") data = { self.param_map['username']: self.username, self.param_map['password']: password } res = requests.post(self.auth_url, json=data) try: data = res.json() self.token = data['token'] return self.token except: return None
Example #5
Source File: node.py From Paradrop with Apache License 2.0 | 6 votes |
def set_password(ctx): """ Change the local admin password. Set the password required by `pdtools node login` and the local web-based administration page. """ username = builtins.input("Username: ") while True: password = getpass.getpass("New password: ") confirm = getpass.getpass("Confirm password: ") if password == confirm: break else: print("Passwords do not match.") click.echo("Next, if prompted, you should enter the current username and password.") client = ctx.obj['client'] result = client.set_password(username, password) click.echo(util.format_result(result)) return result
Example #6
Source File: device.py From Paradrop with Apache License 2.0 | 6 votes |
def password(ctx): """ Change the router admin password. """ url = ctx.obj['base_url'] + "/password/change" username = builtins.input("Username: ") while True: password = getpass.getpass("New password: ") confirm = getpass.getpass("Confirm password: ") if password == confirm: break else: print("Passwords do not match.") data = { "username": username, "password": password } router_request("POST", url, json=data)
Example #7
Source File: nsidc_icesat2_zarr.py From read-ICESat-2 with MIT License | 6 votes |
def attributes_encoder(attr): """Custom encoder for copying file attributes in Python 3""" if isinstance(attr, (bytes, bytearray)): return attr.decode('utf-8') if isinstance(attr, (np.int_, np.intc, np.intp, np.int8, np.int16, np.int32, np.int64, np.uint8, np.uint16, np.uint32, np.uint64)): return int(attr) elif isinstance(attr, (np.float_, np.float16, np.float32, np.float64)): return float(attr) elif isinstance(attr, (np.ndarray)): if not isinstance(attr[0], (object)): return attr.tolist() elif isinstance(attr, (np.bool_)): return bool(attr) elif isinstance(attr, (np.void)): return None else: return attr #-- PURPOSE: help module to describe the optional input parameters
Example #8
Source File: protect.py From rm-protection with MIT License | 6 votes |
def protect(protect_args=None): global c flags = '' option_end = False if not protect_args: protect_args = argv[1:] for arg in protect_args: if arg == '--': option_end = True elif (arg.startswith("-") and not option_end): flags = flags + arg[arg.rfind('-') + 1:] elif arg in c.invalid: pprint('"." and ".." may not be protected') else: path = abspath(expv(expu(arg))) evalpath = dirname(path) + "/." + basename(path) + c.suffix if not exists(path): pprint("Warning: " + path + " does not exist") with open(evalpath, "w") as f: question = input("Question for " + path + ": ") answer = input("Answer: ") f.write(question + "\n" + answer + "\n" + flags.upper())
Example #9
Source File: duct.py From omniduct with MIT License | 6 votes |
def username(self): """ str: Some services require authentication in order to connect to the service, in which case the appropriate username can be specified. If not specified at instantiation, your local login name will be used. If `True` was provided, you will be prompted to type your username at runtime as necessary. If `False` was provided, then `None` will be returned. You can specify a different username at runtime using: `duct.username = '<username>'`. """ if self._username is True: if 'username' not in self.__cached_auth: self.__cached_auth['username'] = input("Enter username for '{}':".format(self.name)) return self.__cached_auth['username'] elif self._username is False: return None elif not self._username: try: username = os.getlogin() except OSError: username = pwd.getpwuid(os.geteuid()).pw_name return username return self._username
Example #10
Source File: lstm_ref.py From ngraph-python with Apache License 2.0 | 6 votes |
def runBatchFpropWithGivenInput(hidden_size, X): """ run the LSTM model through the given input data. The data has dimension (seq_len, batch_size, hidden_size) """ # seq_len = X.shape[0] # batch_size = X.shape[1] input_size = X.shape[2] WLSTM = LSTM.init(input_size, hidden_size) # batch forward Hout, cprev, hprev, batch_cache = LSTM.forward(X, WLSTM) IFOGf = batch_cache['IFOGf'] Ct = batch_cache['Ct'] return Hout, IFOGf, Ct, batch_cache
Example #11
Source File: utils.py From rasa_wechat with Apache License 2.0 | 6 votes |
def request_input(valid_values, prompt=None, max_suggested=3): def wrong_input_message(): print("Invalid answer, only {}{} allowed\n".format( ", ".join(valid_values[:max_suggested]), ",..." if len(valid_values) > max_suggested else "")) while True: try: input_value = input(prompt) if prompt else input() if input_value not in valid_values: wrong_input_message() continue except ValueError: wrong_input_message() continue return input_value
Example #12
Source File: Tomcat CVE-2017-12617.py From PayloadsAllTheThings with MIT License | 6 votes |
def shell(url,f): while True: headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'} cmd=input("$ ") payload={'cmd':cmd} if cmd=="q" or cmd=="Q": break re=requests.get(str(url)+"/"+str(f),params=payload,headers=headers) re=str(re.content) t=removetags(re) print(t) #print bcolors.HEADER+ banner+bcolors.ENDC
Example #13
Source File: user.py From passhport with GNU Affero General Public License v3.0 | 6 votes |
def prompt_edit(req): """Prompt user to obtain data to request""" name = input("Name of the user you want to modify: ") if req.show("user", {"<name>": name}) == 0: new_name = input("New name: ") new_sshkey = input("New SSH key: ") new_comment = input("New comment: ") if len(new_comment.strip()) == 0: answer = input("Remove original comment? [y/N]") if answer == "y": new_comment = "PASSHPORTREMOVECOMMENT" return {"<name>": name, "--newname": new_name, "--newsshkey": new_sshkey, "--newcomment": new_comment} return None
Example #14
Source File: targetgroup.py From passhport with GNU Affero General Public License v3.0 | 6 votes |
def prompt_edit(req): """Prompt targetgroup to obtain data to request""" name = input("Name of the targetgroup you want to modify: ") if req.show("targetgroup", {"<name>": name}) == 0: new_name = input("New name: ") new_comment = input("New comment: ") if len(new_comment.strip()) == 0: answer = input("Remove original comment? [y/N]") if answer == "y": new_comment = "PASSHPORTREMOVECOMMENT" return {"<name>": name, "--newname": new_name, "--newcomment": new_comment} return None
Example #15
Source File: in_db.py From bibcure with GNU Affero General Public License v3.0 | 6 votes |
def update_bibs_in(grouped_bibs, db_abbrev): actions = { "y": lambda items: [update_in(bibs, db_abbrev) for bibs in items], "m": lambda items: [manual_update_in(bibs, db_abbrev) for bibs in items], "n": lambda items: items } print("\n ") action = input("Abbreviate everything?" + "y(yes, automatic)/m(manual)/n(do nothing)") grouped_bibs.sort(key=operator.itemgetter('journal')) grouped_by_journal = [] for key, items in groupby(grouped_bibs, lambda i: i["journal"]): grouped_by_journal.append(list(items)) if action in ("y", "m", "n"): updated_bibs = actions.get(action)(grouped_by_journal) else: return update_bibs_in(grouped_bibs, db_abbrev) updated_bibs = reduce(lambda a, b: a+b, updated_bibs) return updated_bibs
Example #16
Source File: requests_functions.py From passhport with GNU Affero General Public License v3.0 | 6 votes |
def ask_confirmation(prompt_confirmation): """Same as input() but check if user key in a correct input, return True if the user confirms, false otherwise. """ # Hack for the sake of compatibility between 2.7 and 3.4 sys.stdout.write(prompt_confirmation) confirmation = str.upper(input("")) # Loop until user types [y/N] while confirmation != "Y" and confirmation != "N" and confirmation: print("You didn't type 'Y' or 'N', please try again.") sys.stdout.write(prompt_confirmation) confirmation = str.upper(input("")) if confirmation == "Y": return True return False
Example #17
Source File: lstm_ref.py From ngraph-python with Apache License 2.0 | 6 votes |
def runBatchBpropWithGivenDelta(hidden_size, batch_cache, delta): """ run the LSTM model through the given input errors. The data has dimension (seq_len, batch_size, hidden_size) """ dH = delta # get the batched version gradients dX, dWLSTM, dc0, dh0 = LSTM.backward(dH, batch_cache) input_size = dWLSTM.shape[0] - hidden_size - 1 dWrecur = dWLSTM[-hidden_size:, :] dWinput = dWLSTM[1:input_size + 1, :] db = dWLSTM[0, :] return dX, dWrecur, dWinput, db, dWLSTM # ------------------- # TEST CASES # -------------------
Example #18
Source File: out_db.py From bibcure with GNU Affero General Public License v3.0 | 6 votes |
def update_out(bibs, db_abbrev): is_abreviation = input( "'{}' is a abreviation?y(yes)n(no): ".format(bibs[0]["journal"]) ) if is_abreviation == "y": full_name = input("Insert journal name:\n") abreviation = bibs[0]["journal"] elif is_abreviation == "n": abreviation = input("Insert abreviation:\n") full_name = bibs[0]["journal"] else: return update_out(bibs, db_abbrev) db_abbrev.insert(full_name, abreviation) for i, bib in enumerate(bibs): bibs[i]["journal"] = abreviation return bibs
Example #19
Source File: utilities_general_v2.py From MachineLearningSamples-ImageClassificationUsingCntk with MIT License | 5 votes |
def deleteAllFilesInDirectory(directory, fileEndswithString, boPromptUser = False): if boPromptUser: userInput = eval(input('--> INPUT: Press "y" to delete files in directory ' + directory + ": ")) if not (userInput.lower() == 'y' or userInput.lower() == 'yes'): print("User input is %s: exiting now." % userInput) exit() for filename in getFilesInDirectory(directory): if fileEndswithString == None or filename.lower().endswith(fileEndswithString): deleteFile(directory + "/" + filename) ################################################# # 1D list #################################################
Example #20
Source File: prompts.py From clusterfuzz with Apache License 2.0 | 5 votes |
def get_string(prompt): """Prompt the user for a string from console input.""" return input(prompt + ': ')
Example #21
Source File: test_upload.py From gee_asset_manager with Apache License 2.0 | 5 votes |
def get_username(): return input("\nUser name: ")
Example #22
Source File: test_upload.py From gee_asset_manager with Apache License 2.0 | 5 votes |
def mockreturn_pass(): return input("Password: ")
Example #23
Source File: prompt_functions.py From passhport with GNU Affero General Public License v3.0 | 5 votes |
def delete(obj): """Ask arguments for deleting an existing object""" name = input("Name: ") if req.show(obj, {"<name>": name}) == 0: confirmed = req.ask_confirmation("Are you sure you want to delete " + \ name + "? [y/N] ") if confirmed: return req.get(config.url_passhport + obj + "/delete/" + name) else: print("Operation aborted.") return None
Example #24
Source File: prompt_functions.py From passhport with GNU Affero General Public License v3.0 | 5 votes |
def show(obj): """Ask arguments for showing the object""" name = input("Name: ") return req.show(obj, {"<name>": name})
Example #25
Source File: prompt_functions.py From passhport with GNU Affero General Public License v3.0 | 5 votes |
def checkaccess(obj): """Search a target and test the connectivity""" pattern = input("Pattern: ") return req.checkaccess(obj, {"<pattern>": pattern})
Example #26
Source File: prompt_functions.py From passhport with GNU Affero General Public License v3.0 | 5 votes |
def search(obj): """Search an object of this type which match the pattern""" pattern = input("Pattern: ") return req.search(obj, {"<pattern>": pattern})
Example #27
Source File: usergroup.py From passhport with GNU Affero General Public License v3.0 | 5 votes |
def prompt_rmusergroup(): """Prompt user to obtain data to remove a usergroup""" subusergroupname = input("Subsergroupname: ") usergroupname = input("Usergroupname: ") return {"<subusergroupname>": subusergroupname, "<usergroupname>": usergroupname}
Example #28
Source File: nsidc_icesat2_sync.py From read-ICESat-2 with MIT License | 5 votes |
def http_pull_file(remote_file,remote_mtime,local_file,LIST,CLOBBER,MODE): #-- if file exists in file system: check if remote file is newer TEST = False OVERWRITE = ' (clobber)' #-- check if local version of file exists if os.access(local_file, os.F_OK): #-- check last modification time of local file local_mtime = os.stat(local_file).st_mtime #-- if remote file is newer: overwrite the local file if (remote_mtime > local_mtime): TEST = True OVERWRITE = ' (overwrite)' else: TEST = True OVERWRITE = ' (new)' #-- if file does not exist locally, is to be overwritten, or CLOBBER is set if TEST or CLOBBER: #-- output string for printing files transferred output = '{0} -->\n\t{1}{2}\n'.format(remote_file,local_file,OVERWRITE) #-- if executing copy command (not only printing the files) if not LIST: #-- Create and submit request. There are a wide range of exceptions #-- that can be thrown here, including HTTPError and URLError. request = urllib2.Request(remote_file) response = urllib2.urlopen(request) #-- chunked transfer encoding size CHUNK = 16 * 1024 #-- copy contents to local file using chunked transfer encoding #-- transfer should work properly with ascii and binary data formats with open(local_file, 'wb') as f: shutil.copyfileobj(response, f, CHUNK) #-- keep remote modification time of file and local access time os.utime(local_file, (os.stat(local_file).st_atime, remote_mtime)) os.chmod(local_file, MODE) #-- return the output string return output #-- PURPOSE: help module to describe the optional input parameters
Example #29
Source File: usergroup.py From passhport with GNU Affero General Public License v3.0 | 5 votes |
def prompt_addusergroup(): """Prompt user to obtain data to add a usergroup""" subusergroupname = input("Subusergroupname: ") usergroupname = input("Usergroupname: ") return {"<subusergroupname>": subusergroupname, "<usergroupname>": usergroupname}
Example #30
Source File: in_db.py From bibcure with GNU Affero General Public License v3.0 | 5 votes |
def manual_update_in(bibs, db_abbrev): actions = { "y": lambda: update_in(bibs, db_abbrev), "n": lambda: bibs, "c": lambda: update_in(bibs, db_abbrev, custom=True) } question = "Replace '{}' for {}? y(yes)/n(no)/c(custom): " question = question.format(bibs[0]["journal"], bibs[0]["_text"]) action = input(question) try: return actions.get(action)() except TypeError: return manual_update_in(bibs, db_abbrev)