MCPcopy
hub / github.com/corpnewt/GenSMBIOS / grab

Method grab

Scripts/utils.py:136–170  ·  view source on GitHub ↗
(self, prompt, **kwargs)

Source from the content-addressed store, hash-verified

134 test_path = "\\".join([x.replace("\\", "") for x in test_path.split("\\\\")])
135
136 def grab(self, prompt, **kwargs):
137 # Takes a prompt, a default, and a timeout and shows it with that timeout
138 # returning the result
139 timeout = kwargs.get("timeout", 0)
140 default = kwargs.get("default", None)
141 # If we don't have a timeout - then skip the timed sections
142 if timeout <= 0:
143 if sys.version_info >= (3, 0):
144 return input(prompt)
145 else:
146 return str(raw_input(prompt))
147 # Write our prompt
148 sys.stdout.write(prompt)
149 sys.stdout.flush()
150 if os.name == "nt":
151 start_time = time.time()
152 i = ''
153 while True:
154 if msvcrt.kbhit():
155 c = msvcrt.getche()
156 if ord(c) == 13: # enter_key
157 break
158 elif ord(c) >= 32: #space_char
159 i += c
160 if len(i) == 0 and (time.time() - start_time) > timeout:
161 break
162 else:
163 i, o, e = select.select( [sys.stdin], [], [], timeout )
164 if i:
165 i = sys.stdin.readline().strip()
166 print('') # needed to move to next line
167 if len(i) > 0:
168 return i
169 else:
170 return default
171
172 def cls(self):
173 os.system('cls' if os.name=='nt' else 'clear')

Callers 7

_get_macserialMethod · 0.80
_get_remote_versionMethod · 0.80
_get_plistMethod · 0.80
_generate_smbiosMethod · 0.80
_list_currentMethod · 0.80
get_additional_argsMethod · 0.80
mainMethod · 0.80

Calls 1

writeMethod · 0.80

Tested by

no test coverage detected