text
stringlengths 0
828
|
---|
for key in index_names |
] |
write_rec( |
obj.__class__.get_table_name(), |
obj.id, |
obj.to_data(), |
index_name_values |
)" |
197,"def call(command, stdin=None, stdout=subprocess.PIPE, env=os.environ, cwd=None, |
shell=False, output_log_level=logging.INFO, sensitive_info=False): |
"""""" Better, smarter call logic """""" |
if not sensitive_info: |
logger.debug(""calling command: %s"" % command) |
else: |
logger.debug(""calling command with sensitive information"") |
try: |
args = command if shell else whitespace_smart_split(command) |
kw = {} |
if not shell and not which(args[0], cwd=cwd): |
raise CommandMissingException(args[0]) |
if shell: |
kw['shell'] = True |
process = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=stdout, |
stderr=subprocess.STDOUT, env=env, cwd=cwd, |
**kw) |
output = process.communicate(input=stdin)[0] |
if output is not None: |
try: |
logger.log(output_log_level, output.decode('utf-8')) |
except UnicodeDecodeError: |
pass |
return (process.returncode, output) |
except OSError: |
e = sys.exc_info()[1] |
if not sensitive_info: |
logger.exception(""Error running command: %s"" % command) |
logger.error(""Root directory: %s"" % cwd) |
if stdin: |
logger.error(""stdin: %s"" % stdin) |
raise e" |
198,"def whitespace_smart_split(command): |
"""""" |
Split a command by whitespace, taking care to not split on |
whitespace within quotes. |
>>> whitespace_smart_split(""test this \\\""in here\\\"" again"") |
['test', 'this', '""in here""', 'again'] |
"""""" |
return_array = [] |
s = """" |
in_double_quotes = False |
escape = False |
for c in command: |
if c == '""': |
if in_double_quotes: |
if escape: |
s += c |
escape = False |
else: |
s += c |
in_double_quotes = False |
else: |
in_double_quotes = True |
s += c |
else: |
if in_double_quotes: |
if c == '\\': |
escape = True |
s += c |
else: |
escape = False |
s += c |
else: |
if c == ' ': |
return_array.append(s) |
s = """" |
else: |
s += c |
if s != """": |
return_array.append(s) |
return return_array" |
199,"def skip(stackframe=1): |
"""""" |
Must be called from within `__enter__()`. Performs some magic to have a |
#ContextSkipped exception be raised the moment the with context is entered. |
The #ContextSkipped must then be handled in `__exit__()` to suppress the |
propagation of the exception. |
> Important: This function does not raise an exception by itself, thus |
> the `__enter__()` method will continue to execute after using this function. |
"""""" |
def trace(frame, event, args): |
raise ContextSkipped |
sys.settrace(lambda *args, **kwargs: None) |
frame = sys._getframe(stackframe + 1) |
frame.f_trace = trace" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.