text
stringlengths 0
828
|
---|
""""""
|
args = shlex.split(self.cmd)
|
proc = Popen(args, stdout=PIPE, stderr=PIPE)
|
out, err = proc.communicate()
|
out, err = out.decode(""utf8""), err.decode(""utf8"")
|
exitcode = proc.returncode
|
#
|
return exitcode, out, err"
|
94,"def execute_in_background(self):
|
""""""Executes a (shell) command in the background
|
:return: the process' pid
|
""""""
|
# http://stackoverflow.com/questions/1605520
|
args = shlex.split(self.cmd)
|
p = Popen(args)
|
return p.pid"
|
95,"def keep_alive(self):
|
""""""Keeps a process alive. If the process terminates, it will restart it
|
The terminated processes become zombies. They die when their parent
|
terminates
|
""""""
|
while True:
|
pid = self.execute_in_background()
|
p = psutil.Process(pid)
|
while p.is_running() and str(p.status) != 'zombie':
|
os.system('sleep 5')"
|
96,"def get_free_mb(folder):
|
"""""" Return folder/drive free space (in bytes)
|
""""""
|
if platform.system() == 'Windows':
|
free_bytes = ctypes.c_ulonglong(0)
|
ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(folder), None, None, ctypes.pointer(free_bytes))
|
return free_bytes.value/1024/1024
|
else:
|
st = os.statvfs(folder)
|
return st.f_bavail * st.f_frsize/1024/1024"
|
97,"def increment_title(title):
|
""""""
|
Increments a string that ends in a number
|
""""""
|
count = re.search('\d+$', title).group(0)
|
new_title = title[:-(len(count))] + str(int(count)+1)
|
return new_title"
|
98,"def check_limit(self, limit):
|
""""""
|
Checks if the given limit is valid.
|
A limit must be > 0 to be considered valid.
|
Raises ValueError when the *limit* is not > 0.
|
""""""
|
if limit > 0:
|
self.limit = limit
|
else:
|
raise ValueError(""Rule limit must be strictly > 0 ({0} given)""
|
.format(limit))
|
return self"
|
99,"def build_filter(self, filter):
|
""""""
|
Tries to build a :class:`filter.Filter` instance from the given filter.
|
Raises ValueError if the :class:`filter.Filter` object can't be build
|
from the given filter.
|
""""""
|
try:
|
self.filter = Filter.from_string(filter, self.limit)
|
except ValueError:
|
raise
|
return self"
|
100,"def build_action(self, action):
|
""""""
|
Tries to build an :class:`action.Action` instance from the given
|
action.
|
Raises ValueError if the :class:`action.Action` object can't be build
|
from the given action.
|
""""""
|
try:
|
self.action = Action.from_string(action)
|
except ValueError:
|
raise
|
return self"
|
101,"def get_args():
|
""""""
|
request the arguments for running
|
""""""
|
ap = argparse.ArgumentParser(description=""Create frames for a movie that can be compiled using ffmpeg"")
|
ap.add_argument(""start"", help=""date string as start time"")
|
ap.add_argument(""end"", help=""date string as end time"")
|
ap.add_argument(""step"", type=float, help=""fraction of a day to step by"")
|
ap.add_argument(""--config"", help=""path to a config file"", default=""config.json"")
|
return ap.parse_args()"
|
102,"def make_three_color(data, time, step, config, shape=(1280, 1280), lower_val=(0, 0, 0), upper_val=(2.5, 2.5, 2.5)):
|
""""""
|
create a three color image according to the config file
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.