id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
10,900
soravux/scoop
scoop/utils.py
getHostsFromPBS
def getHostsFromPBS(): """Return a host list in a PBS environment""" # See above comment about Counter with open(os.environ["PBS_NODEFILE"], 'r') as hosts: hostlist = groupTogether(hosts.read().split()) retVal = [] for key, group in groupby(hostlist): retVal.append((key, ...
python
def getHostsFromPBS(): """Return a host list in a PBS environment""" # See above comment about Counter with open(os.environ["PBS_NODEFILE"], 'r') as hosts: hostlist = groupTogether(hosts.read().split()) retVal = [] for key, group in groupby(hostlist): retVal.append((key, ...
[ "def", "getHostsFromPBS", "(", ")", ":", "# See above comment about Counter", "with", "open", "(", "os", ".", "environ", "[", "\"PBS_NODEFILE\"", "]", ",", "'r'", ")", "as", "hosts", ":", "hostlist", "=", "groupTogether", "(", "hosts", ".", "read", "(", ")",...
Return a host list in a PBS environment
[ "Return", "a", "host", "list", "in", "a", "PBS", "environment" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/utils.py#L225-L233
10,901
soravux/scoop
scoop/utils.py
getHostsFromSGE
def getHostsFromSGE(): """Return a host list in a SGE environment""" with open(os.environ["PE_HOSTFILE"], 'r') as hosts: return [(host.split()[0], int(host.split()[1])) for host in hosts]
python
def getHostsFromSGE(): """Return a host list in a SGE environment""" with open(os.environ["PE_HOSTFILE"], 'r') as hosts: return [(host.split()[0], int(host.split()[1])) for host in hosts]
[ "def", "getHostsFromSGE", "(", ")", ":", "with", "open", "(", "os", ".", "environ", "[", "\"PE_HOSTFILE\"", "]", ",", "'r'", ")", "as", "hosts", ":", "return", "[", "(", "host", ".", "split", "(", ")", "[", "0", "]", ",", "int", "(", "host", ".",...
Return a host list in a SGE environment
[ "Return", "a", "host", "list", "in", "a", "SGE", "environment" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/utils.py#L236-L239
10,902
soravux/scoop
scoop/utils.py
getWorkerQte
def getWorkerQte(hosts): """Return the number of workers to launch depending on the environment""" if "SLURM_NTASKS" in os.environ: return int(os.environ["SLURM_NTASKS"]) elif "PBS_NP" in os.environ: return int(os.environ["PBS_NP"]) elif "NSLOTS" in os.environ: return int(os.envi...
python
def getWorkerQte(hosts): """Return the number of workers to launch depending on the environment""" if "SLURM_NTASKS" in os.environ: return int(os.environ["SLURM_NTASKS"]) elif "PBS_NP" in os.environ: return int(os.environ["PBS_NP"]) elif "NSLOTS" in os.environ: return int(os.envi...
[ "def", "getWorkerQte", "(", "hosts", ")", ":", "if", "\"SLURM_NTASKS\"", "in", "os", ".", "environ", ":", "return", "int", "(", "os", ".", "environ", "[", "\"SLURM_NTASKS\"", "]", ")", "elif", "\"PBS_NP\"", "in", "os", ".", "environ", ":", "return", "int...
Return the number of workers to launch depending on the environment
[ "Return", "the", "number", "of", "workers", "to", "launch", "depending", "on", "the", "environment" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/utils.py#L242-L251
10,903
soravux/scoop
scoop/encapsulation.py
functionFactory
def functionFactory(in_code, name, defaults, globals_, imports): """Creates a function at runtime using binary compiled inCode""" def generatedFunction(): pass generatedFunction.__code__ = marshal.loads(in_code) generatedFunction.__name__ = name generatedFunction.__defaults = defaults ge...
python
def functionFactory(in_code, name, defaults, globals_, imports): """Creates a function at runtime using binary compiled inCode""" def generatedFunction(): pass generatedFunction.__code__ = marshal.loads(in_code) generatedFunction.__name__ = name generatedFunction.__defaults = defaults ge...
[ "def", "functionFactory", "(", "in_code", ",", "name", ",", "defaults", ",", "globals_", ",", "imports", ")", ":", "def", "generatedFunction", "(", ")", ":", "pass", "generatedFunction", ".", "__code__", "=", "marshal", ".", "loads", "(", "in_code", ")", "...
Creates a function at runtime using binary compiled inCode
[ "Creates", "a", "function", "at", "runtime", "using", "binary", "compiled", "inCode" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/encapsulation.py#L41-L53
10,904
soravux/scoop
scoop/encapsulation.py
makeLambdaPicklable
def makeLambdaPicklable(lambda_function): """Take input lambda function l and makes it picklable.""" if isinstance(lambda_function, type(lambda: None)) and lambda_function.__name__ == '<lambda>': def __reduce_ex__(proto): # TODO: argdefs, closure return unpickle...
python
def makeLambdaPicklable(lambda_function): """Take input lambda function l and makes it picklable.""" if isinstance(lambda_function, type(lambda: None)) and lambda_function.__name__ == '<lambda>': def __reduce_ex__(proto): # TODO: argdefs, closure return unpickle...
[ "def", "makeLambdaPicklable", "(", "lambda_function", ")", ":", "if", "isinstance", "(", "lambda_function", ",", "type", "(", "lambda", ":", "None", ")", ")", "and", "lambda_function", ".", "__name__", "==", "'<lambda>'", ":", "def", "__reduce_ex__", "(", "pro...
Take input lambda function l and makes it picklable.
[ "Take", "input", "lambda", "function", "l", "and", "makes", "it", "picklable", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/encapsulation.py#L143-L151
10,905
soravux/scoop
examples/dependency/sortingnetwork.py
SortingNetwork.addConnector
def addConnector(self, wire1, wire2): """Add a connector between wire1 and wire2 in the network.""" if wire1 == wire2: return if wire1 > wire2: wire1, wire2 = wire2, wire1 try: last_level = self[-1] except IndexError: ...
python
def addConnector(self, wire1, wire2): """Add a connector between wire1 and wire2 in the network.""" if wire1 == wire2: return if wire1 > wire2: wire1, wire2 = wire2, wire1 try: last_level = self[-1] except IndexError: ...
[ "def", "addConnector", "(", "self", ",", "wire1", ",", "wire2", ")", ":", "if", "wire1", "==", "wire2", ":", "return", "if", "wire1", ">", "wire2", ":", "wire1", ",", "wire2", "=", "wire2", ",", "wire1", "try", ":", "last_level", "=", "self", "[", ...
Add a connector between wire1 and wire2 in the network.
[ "Add", "a", "connector", "between", "wire1", "and", "wire2", "in", "the", "network", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/examples/dependency/sortingnetwork.py#L43-L63
10,906
soravux/scoop
examples/dependency/sortingnetwork.py
SortingNetwork.sort
def sort(self, values): """Sort the values in-place based on the connectors in the network.""" for level in self: for wire1, wire2 in level: if values[wire1] > values[wire2]: values[wire1], values[wire2] = values[wire2], values[wire1]
python
def sort(self, values): """Sort the values in-place based on the connectors in the network.""" for level in self: for wire1, wire2 in level: if values[wire1] > values[wire2]: values[wire1], values[wire2] = values[wire2], values[wire1]
[ "def", "sort", "(", "self", ",", "values", ")", ":", "for", "level", "in", "self", ":", "for", "wire1", ",", "wire2", "in", "level", ":", "if", "values", "[", "wire1", "]", ">", "values", "[", "wire2", "]", ":", "values", "[", "wire1", "]", ",", ...
Sort the values in-place based on the connectors in the network.
[ "Sort", "the", "values", "in", "-", "place", "based", "on", "the", "connectors", "in", "the", "network", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/examples/dependency/sortingnetwork.py#L65-L70
10,907
soravux/scoop
examples/dependency/sortingnetwork.py
SortingNetwork.draw
def draw(self): """Return an ASCII representation of the network.""" str_wires = [["-"]*7 * self.depth] str_wires[0][0] = "0" str_wires[0][1] = " o" str_spaces = [] for i in range(1, self.dimension): str_wires.append(["-"]*7 * self.depth) str_spac...
python
def draw(self): """Return an ASCII representation of the network.""" str_wires = [["-"]*7 * self.depth] str_wires[0][0] = "0" str_wires[0][1] = " o" str_spaces = [] for i in range(1, self.dimension): str_wires.append(["-"]*7 * self.depth) str_spac...
[ "def", "draw", "(", "self", ")", ":", "str_wires", "=", "[", "[", "\"-\"", "]", "*", "7", "*", "self", ".", "depth", "]", "str_wires", "[", "0", "]", "[", "0", "]", "=", "\"0\"", "str_wires", "[", "0", "]", "[", "1", "]", "=", "\" o\"", "str_...
Return an ASCII representation of the network.
[ "Return", "an", "ASCII", "representation", "of", "the", "network", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/examples/dependency/sortingnetwork.py#L88-L116
10,908
soravux/scoop
bench/process_debug.py
getWorkersName
def getWorkersName(data): """Returns the list of the names of the workers sorted alphabetically""" names = [fichier for fichier in data.keys()] names.sort() try: names.remove("broker") except ValueError: pass return names
python
def getWorkersName(data): """Returns the list of the names of the workers sorted alphabetically""" names = [fichier for fichier in data.keys()] names.sort() try: names.remove("broker") except ValueError: pass return names
[ "def", "getWorkersName", "(", "data", ")", ":", "names", "=", "[", "fichier", "for", "fichier", "in", "data", ".", "keys", "(", ")", "]", "names", ".", "sort", "(", ")", "try", ":", "names", ".", "remove", "(", "\"broker\"", ")", "except", "ValueErro...
Returns the list of the names of the workers sorted alphabetically
[ "Returns", "the", "list", "of", "the", "names", "of", "the", "workers", "sorted", "alphabetically" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/bench/process_debug.py#L41-L49
10,909
soravux/scoop
bench/process_debug.py
importData
def importData(directory): """Parse the input files and return two dictionnaries""" dataTask = OrderedDict() dataQueue = OrderedDict() for fichier in sorted(os.listdir(directory)): try: with open("{directory}/{fichier}".format(**locals()), 'rb') as f: fileName, fileTy...
python
def importData(directory): """Parse the input files and return two dictionnaries""" dataTask = OrderedDict() dataQueue = OrderedDict() for fichier in sorted(os.listdir(directory)): try: with open("{directory}/{fichier}".format(**locals()), 'rb') as f: fileName, fileTy...
[ "def", "importData", "(", "directory", ")", ":", "dataTask", "=", "OrderedDict", "(", ")", "dataQueue", "=", "OrderedDict", "(", ")", "for", "fichier", "in", "sorted", "(", "os", ".", "listdir", "(", "directory", ")", ")", ":", "try", ":", "with", "ope...
Parse the input files and return two dictionnaries
[ "Parse", "the", "input", "files", "and", "return", "two", "dictionnaries" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/bench/process_debug.py#L51-L66
10,910
soravux/scoop
bench/process_debug.py
getTimes
def getTimes(dataTasks): """Get the start time and the end time of data in milliseconds""" global begin_time start_time, end_time = float('inf'), 0 for fichier, vals in dataTask.items(): try: if hasattr(vals, 'values'): tmp_start_time = min([a['start_time'] for a in v...
python
def getTimes(dataTasks): """Get the start time and the end time of data in milliseconds""" global begin_time start_time, end_time = float('inf'), 0 for fichier, vals in dataTask.items(): try: if hasattr(vals, 'values'): tmp_start_time = min([a['start_time'] for a in v...
[ "def", "getTimes", "(", "dataTasks", ")", ":", "global", "begin_time", "start_time", ",", "end_time", "=", "float", "(", "'inf'", ")", ",", "0", "for", "fichier", ",", "vals", "in", "dataTask", ".", "items", "(", ")", ":", "try", ":", "if", "hasattr", ...
Get the start time and the end time of data in milliseconds
[ "Get", "the", "start", "time", "and", "the", "end", "time", "of", "data", "in", "milliseconds" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/bench/process_debug.py#L79-L95
10,911
soravux/scoop
bench/process_debug.py
WorkersDensity
def WorkersDensity(dataTasks): """Return the worker density data for the graph.""" start_time, end_time = getTimes(dataTasks) graphdata = [] for name in getWorkersName(dataTasks): vals = dataTasks[name] if hasattr(vals, 'values'): # Data from worker workerdata =...
python
def WorkersDensity(dataTasks): """Return the worker density data for the graph.""" start_time, end_time = getTimes(dataTasks) graphdata = [] for name in getWorkersName(dataTasks): vals = dataTasks[name] if hasattr(vals, 'values'): # Data from worker workerdata =...
[ "def", "WorkersDensity", "(", "dataTasks", ")", ":", "start_time", ",", "end_time", "=", "getTimes", "(", "dataTasks", ")", "graphdata", "=", "[", "]", "for", "name", "in", "getWorkersName", "(", "dataTasks", ")", ":", "vals", "=", "dataTasks", "[", "name"...
Return the worker density data for the graph.
[ "Return", "the", "worker", "density", "data", "for", "the", "graph", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/bench/process_debug.py#L97-L130
10,912
soravux/scoop
bench/process_debug.py
plotDensity
def plotDensity(dataTask, filename): """Plot the worker density graph""" #def format_worker(x, pos=None): # """Formats the worker name""" # #workers = filter (lambda a: a[:6] != "broker", dataTask.keys()) # workers = [a for a in dataTask.keys() if a[:6] != "broker"] # return workers...
python
def plotDensity(dataTask, filename): """Plot the worker density graph""" #def format_worker(x, pos=None): # """Formats the worker name""" # #workers = filter (lambda a: a[:6] != "broker", dataTask.keys()) # workers = [a for a in dataTask.keys() if a[:6] != "broker"] # return workers...
[ "def", "plotDensity", "(", "dataTask", ",", "filename", ")", ":", "#def format_worker(x, pos=None):", "# \"\"\"Formats the worker name\"\"\"", "# #workers = filter (lambda a: a[:6] != \"broker\", dataTask.keys())", "# workers = [a for a in dataTask.keys() if a[:6] != \"broker\"]", "...
Plot the worker density graph
[ "Plot", "the", "worker", "density", "graph" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/bench/process_debug.py#L132-L173
10,913
soravux/scoop
bench/process_debug.py
plotBrokerQueue
def plotBrokerQueue(dataTask, filename): """Generates the broker queue length graphic.""" print("Plotting broker queue length for {0}.".format(filename)) plt.figure() # Queue length plt.subplot(211) for fichier, vals in dataTask.items(): if type(vals) == list: timestamps = l...
python
def plotBrokerQueue(dataTask, filename): """Generates the broker queue length graphic.""" print("Plotting broker queue length for {0}.".format(filename)) plt.figure() # Queue length plt.subplot(211) for fichier, vals in dataTask.items(): if type(vals) == list: timestamps = l...
[ "def", "plotBrokerQueue", "(", "dataTask", ",", "filename", ")", ":", "print", "(", "\"Plotting broker queue length for {0}.\"", ".", "format", "(", "filename", ")", ")", "plt", ".", "figure", "(", ")", "# Queue length", "plt", ".", "subplot", "(", "211", ")",...
Generates the broker queue length graphic.
[ "Generates", "the", "broker", "queue", "length", "graphic", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/bench/process_debug.py#L175-L209
10,914
soravux/scoop
bench/process_debug.py
getWorkerInfo
def getWorkerInfo(dataTask): """Returns the total execution time and task quantity by worker""" workertime = [] workertasks = [] for fichier, vals in dataTask.items(): if hasattr(vals, 'values'): #workers_names.append(fichier) # Data from worker totaltime = su...
python
def getWorkerInfo(dataTask): """Returns the total execution time and task quantity by worker""" workertime = [] workertasks = [] for fichier, vals in dataTask.items(): if hasattr(vals, 'values'): #workers_names.append(fichier) # Data from worker totaltime = su...
[ "def", "getWorkerInfo", "(", "dataTask", ")", ":", "workertime", "=", "[", "]", "workertasks", "=", "[", "]", "for", "fichier", ",", "vals", "in", "dataTask", ".", "items", "(", ")", ":", "if", "hasattr", "(", "vals", ",", "'values'", ")", ":", "#wor...
Returns the total execution time and task quantity by worker
[ "Returns", "the", "total", "execution", "time", "and", "task", "quantity", "by", "worker" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/bench/process_debug.py#L234-L246
10,915
soravux/scoop
bench/process_debug.py
timelines
def timelines(fig, y, xstart, xstop, color='b'): """Plot timelines at y from xstart to xstop with given color.""" fig.hlines(y, xstart, xstop, color, lw=4) fig.vlines(xstart, y+0.03, y-0.03, color, lw=2) fig.vlines(xstop, y+0.03, y-0.03, color, lw=2)
python
def timelines(fig, y, xstart, xstop, color='b'): """Plot timelines at y from xstart to xstop with given color.""" fig.hlines(y, xstart, xstop, color, lw=4) fig.vlines(xstart, y+0.03, y-0.03, color, lw=2) fig.vlines(xstop, y+0.03, y-0.03, color, lw=2)
[ "def", "timelines", "(", "fig", ",", "y", ",", "xstart", ",", "xstop", ",", "color", "=", "'b'", ")", ":", "fig", ".", "hlines", "(", "y", ",", "xstart", ",", "xstop", ",", "color", ",", "lw", "=", "4", ")", "fig", ".", "vlines", "(", "xstart",...
Plot timelines at y from xstart to xstop with given color.
[ "Plot", "timelines", "at", "y", "from", "xstart", "to", "xstop", "with", "given", "color", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/bench/process_debug.py#L331-L335
10,916
soravux/scoop
bench/process_debug.py
plotTimeline
def plotTimeline(dataTask, filename): """Build a timeline""" fig = plt.figure() ax = fig.gca() worker_names = [x for x in dataTask.keys() if "broker" not in x] min_time = getMinimumTime(dataTask) ystep = 1. / (len(worker_names) + 1) y = 0 for worker, vals in dataTask.items(): ...
python
def plotTimeline(dataTask, filename): """Build a timeline""" fig = plt.figure() ax = fig.gca() worker_names = [x for x in dataTask.keys() if "broker" not in x] min_time = getMinimumTime(dataTask) ystep = 1. / (len(worker_names) + 1) y = 0 for worker, vals in dataTask.items(): ...
[ "def", "plotTimeline", "(", "dataTask", ",", "filename", ")", ":", "fig", "=", "plt", ".", "figure", "(", ")", "ax", "=", "fig", ".", "gca", "(", ")", "worker_names", "=", "[", "x", "for", "x", "in", "dataTask", ".", "keys", "(", ")", "if", "\"br...
Build a timeline
[ "Build", "a", "timeline" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/bench/process_debug.py#L350-L383
10,917
soravux/scoop
scoop/launch/workerLaunch.py
Host.setWorker
def setWorker(self, *args, **kwargs): """Add a worker assignation Arguments and order to pass are defined in LAUNCHING_ARGUMENTS Using named args is advised. """ try: la = self.LAUNCHING_ARGUMENTS(*args, **kwargs) except TypeError as e: sco...
python
def setWorker(self, *args, **kwargs): """Add a worker assignation Arguments and order to pass are defined in LAUNCHING_ARGUMENTS Using named args is advised. """ try: la = self.LAUNCHING_ARGUMENTS(*args, **kwargs) except TypeError as e: sco...
[ "def", "setWorker", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "la", "=", "self", ".", "LAUNCHING_ARGUMENTS", "(", "*", "args", ",", "*", "*", "kwargs", ")", "except", "TypeError", "as", "e", ":", "scoop", ".", ...
Add a worker assignation Arguments and order to pass are defined in LAUNCHING_ARGUMENTS Using named args is advised.
[ "Add", "a", "worker", "assignation", "Arguments", "and", "order", "to", "pass", "are", "defined", "in", "LAUNCHING_ARGUMENTS", "Using", "named", "args", "is", "advised", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/launch/workerLaunch.py#L61-L74
10,918
soravux/scoop
scoop/launch/workerLaunch.py
Host._WorkerCommand_environment
def _WorkerCommand_environment(self): """Return list of shell commands to prepare the environment for bootstrap.""" worker = self.workersArguments c = [] if worker.prolog: c.extend([ "source", worker.prolog, "&&", ...
python
def _WorkerCommand_environment(self): """Return list of shell commands to prepare the environment for bootstrap.""" worker = self.workersArguments c = [] if worker.prolog: c.extend([ "source", worker.prolog, "&&", ...
[ "def", "_WorkerCommand_environment", "(", "self", ")", ":", "worker", "=", "self", ".", "workersArguments", "c", "=", "[", "]", "if", "worker", ".", "prolog", ":", "c", ".", "extend", "(", "[", "\"source\"", ",", "worker", ".", "prolog", ",", "\"&&\"", ...
Return list of shell commands to prepare the environment for bootstrap.
[ "Return", "list", "of", "shell", "commands", "to", "prepare", "the", "environment", "for", "bootstrap", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/launch/workerLaunch.py#L80-L106
10,919
soravux/scoop
scoop/launch/workerLaunch.py
Host._WorkerCommand_launcher
def _WorkerCommand_launcher(self): """Return list commands to start the bootstrap process""" return [ self.workersArguments.pythonExecutable, '-m', 'scoop.launch.__main__', str(self.workerAmount), str(self.workersArguments.verbose), ]
python
def _WorkerCommand_launcher(self): """Return list commands to start the bootstrap process""" return [ self.workersArguments.pythonExecutable, '-m', 'scoop.launch.__main__', str(self.workerAmount), str(self.workersArguments.verbose), ]
[ "def", "_WorkerCommand_launcher", "(", "self", ")", ":", "return", "[", "self", ".", "workersArguments", ".", "pythonExecutable", ",", "'-m'", ",", "'scoop.launch.__main__'", ",", "str", "(", "self", ".", "workerAmount", ")", ",", "str", "(", "self", ".", "w...
Return list commands to start the bootstrap process
[ "Return", "list", "commands", "to", "start", "the", "bootstrap", "process" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/launch/workerLaunch.py#L108-L116
10,920
soravux/scoop
scoop/launch/workerLaunch.py
Host._WorkerCommand_options
def _WorkerCommand_options(self): """Return list of options for bootstrap""" worker = self.workersArguments c = [] # If broker is on localhost if self.hostname == worker.brokerHostname: broker = "127.0.0.1" else: broker = worker.brokerHostname ...
python
def _WorkerCommand_options(self): """Return list of options for bootstrap""" worker = self.workersArguments c = [] # If broker is on localhost if self.hostname == worker.brokerHostname: broker = "127.0.0.1" else: broker = worker.brokerHostname ...
[ "def", "_WorkerCommand_options", "(", "self", ")", ":", "worker", "=", "self", ".", "workersArguments", "c", "=", "[", "]", "# If broker is on localhost", "if", "self", ".", "hostname", "==", "worker", ".", "brokerHostname", ":", "broker", "=", "\"127.0.0.1\"", ...
Return list of options for bootstrap
[ "Return", "list", "of", "options", "for", "bootstrap" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/launch/workerLaunch.py#L118-L150
10,921
soravux/scoop
scoop/launch/workerLaunch.py
Host._WorkerCommand_executable
def _WorkerCommand_executable(self): """Return executable and any options to be executed by bootstrap""" worker = self.workersArguments c = [] if worker.executable: c.append(worker.executable) # This trick is used to parse correctly quotes # (ie. myScript.py ...
python
def _WorkerCommand_executable(self): """Return executable and any options to be executed by bootstrap""" worker = self.workersArguments c = [] if worker.executable: c.append(worker.executable) # This trick is used to parse correctly quotes # (ie. myScript.py ...
[ "def", "_WorkerCommand_executable", "(", "self", ")", ":", "worker", "=", "self", ".", "workersArguments", "c", "=", "[", "]", "if", "worker", ".", "executable", ":", "c", ".", "append", "(", "worker", ".", "executable", ")", "# This trick is used to parse cor...
Return executable and any options to be executed by bootstrap
[ "Return", "executable", "and", "any", "options", "to", "be", "executed", "by", "bootstrap" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/launch/workerLaunch.py#L152-L174
10,922
soravux/scoop
scoop/launch/workerLaunch.py
Host._getWorkerCommandList
def _getWorkerCommandList(self): """Generate the workerCommand as list""" c = [] c.extend(self._WorkerCommand_environment()) c.extend(self._WorkerCommand_launcher()) c.extend(self._WorkerCommand_options()) c.extend(self._WorkerCommand_executable()) return c
python
def _getWorkerCommandList(self): """Generate the workerCommand as list""" c = [] c.extend(self._WorkerCommand_environment()) c.extend(self._WorkerCommand_launcher()) c.extend(self._WorkerCommand_options()) c.extend(self._WorkerCommand_executable()) return c
[ "def", "_getWorkerCommandList", "(", "self", ")", ":", "c", "=", "[", "]", "c", ".", "extend", "(", "self", ".", "_WorkerCommand_environment", "(", ")", ")", "c", ".", "extend", "(", "self", ".", "_WorkerCommand_launcher", "(", ")", ")", "c", ".", "ext...
Generate the workerCommand as list
[ "Generate", "the", "workerCommand", "as", "list" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/launch/workerLaunch.py#L176-L184
10,923
soravux/scoop
scoop/launch/workerLaunch.py
Host.launch
def launch(self, tunnelPorts=None): """Launch every worker assigned on this host.""" if self.isLocal(): # Launching local workers c = self._getWorkerCommandList() self.subprocesses.append(subprocess.Popen(c)) else: # Launching remotely ...
python
def launch(self, tunnelPorts=None): """Launch every worker assigned on this host.""" if self.isLocal(): # Launching local workers c = self._getWorkerCommandList() self.subprocesses.append(subprocess.Popen(c)) else: # Launching remotely ...
[ "def", "launch", "(", "self", ",", "tunnelPorts", "=", "None", ")", ":", "if", "self", ".", "isLocal", "(", ")", ":", "# Launching local workers", "c", "=", "self", ".", "_getWorkerCommandList", "(", ")", "self", ".", "subprocesses", ".", "append", "(", ...
Launch every worker assigned on this host.
[ "Launch", "every", "worker", "assigned", "on", "this", "host", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/launch/workerLaunch.py#L190-L214
10,924
soravux/scoop
scoop/_types.py
Future._switch
def _switch(self, future): """Switch greenlet.""" scoop._control.current = self assert self.greenlet is not None, ("No greenlet to switch to:" "\n{0}".format(self.__dict__)) return self.greenlet.switch(future)
python
def _switch(self, future): """Switch greenlet.""" scoop._control.current = self assert self.greenlet is not None, ("No greenlet to switch to:" "\n{0}".format(self.__dict__)) return self.greenlet.switch(future)
[ "def", "_switch", "(", "self", ",", "future", ")", ":", "scoop", ".", "_control", ".", "current", "=", "self", "assert", "self", ".", "greenlet", "is", "not", "None", ",", "(", "\"No greenlet to switch to:\"", "\"\\n{0}\"", ".", "format", "(", "self", ".",...
Switch greenlet.
[ "Switch", "greenlet", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_types.py#L134-L139
10,925
soravux/scoop
scoop/_types.py
Future.cancel
def cancel(self): """If the call is currently being executed or sent for remote execution, then it cannot be cancelled and the method will return False, otherwise the call will be cancelled and the method will return True.""" if self in scoop._control.execQueue.movable: ...
python
def cancel(self): """If the call is currently being executed or sent for remote execution, then it cannot be cancelled and the method will return False, otherwise the call will be cancelled and the method will return True.""" if self in scoop._control.execQueue.movable: ...
[ "def", "cancel", "(", "self", ")", ":", "if", "self", "in", "scoop", ".", "_control", ".", "execQueue", ".", "movable", ":", "self", ".", "exceptionValue", "=", "CancelledError", "(", ")", "scoop", ".", "_control", ".", "futureDict", "[", "self", ".", ...
If the call is currently being executed or sent for remote execution, then it cannot be cancelled and the method will return False, otherwise the call will be cancelled and the method will return True.
[ "If", "the", "call", "is", "currently", "being", "executed", "or", "sent", "for", "remote", "execution", "then", "it", "cannot", "be", "cancelled", "and", "the", "method", "will", "return", "False", "otherwise", "the", "call", "will", "be", "cancelled", "and...
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_types.py#L141-L151
10,926
soravux/scoop
scoop/_types.py
Future.done
def done(self): """Returns True if the call was successfully cancelled or finished running, False otherwise. This function updates the executionQueue so it receives all the awaiting message.""" # Flush the current future in the local buffer (potential deadlock # otherwise) ...
python
def done(self): """Returns True if the call was successfully cancelled or finished running, False otherwise. This function updates the executionQueue so it receives all the awaiting message.""" # Flush the current future in the local buffer (potential deadlock # otherwise) ...
[ "def", "done", "(", "self", ")", ":", "# Flush the current future in the local buffer (potential deadlock", "# otherwise)", "try", ":", "scoop", ".", "_control", ".", "execQueue", ".", "remove", "(", "self", ")", "scoop", ".", "_control", ".", "execQueue", ".", "s...
Returns True if the call was successfully cancelled or finished running, False otherwise. This function updates the executionQueue so it receives all the awaiting message.
[ "Returns", "True", "if", "the", "call", "was", "successfully", "cancelled", "or", "finished", "running", "False", "otherwise", ".", "This", "function", "updates", "the", "executionQueue", "so", "it", "receives", "all", "the", "awaiting", "message", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_types.py#L163-L177
10,927
soravux/scoop
scoop/_types.py
Future.add_done_callback
def add_done_callback(self, callable_, inCallbackType=CallbackType.standard, inCallbackGroup=None): """Attach a callable to the future that will be called when the future is cancelled or finishes running. Callable will be called with the future...
python
def add_done_callback(self, callable_, inCallbackType=CallbackType.standard, inCallbackGroup=None): """Attach a callable to the future that will be called when the future is cancelled or finishes running. Callable will be called with the future...
[ "def", "add_done_callback", "(", "self", ",", "callable_", ",", "inCallbackType", "=", "CallbackType", ".", "standard", ",", "inCallbackGroup", "=", "None", ")", ":", "self", ".", "callback", ".", "append", "(", "callbackEntry", "(", "callable_", ",", "inCallb...
Attach a callable to the future that will be called when the future is cancelled or finishes running. Callable will be called with the future as its only argument. Added callables are called in the order that they were added and are always called in a thread belonging to the process tha...
[ "Attach", "a", "callable", "to", "the", "future", "that", "will", "be", "called", "when", "the", "future", "is", "cancelled", "or", "finishes", "running", ".", "Callable", "will", "be", "called", "with", "the", "future", "as", "its", "only", "argument", "....
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_types.py#L221-L241
10,928
soravux/scoop
scoop/_types.py
FutureQueue.append
def append(self, future): """Append a future to the queue.""" if future._ended() and future.index is None: self.inprogress.add(future) elif future._ended() and future.index is not None: self.ready.append(future) elif future.greenlet is not None: self.i...
python
def append(self, future): """Append a future to the queue.""" if future._ended() and future.index is None: self.inprogress.add(future) elif future._ended() and future.index is not None: self.ready.append(future) elif future.greenlet is not None: self.i...
[ "def", "append", "(", "self", ",", "future", ")", ":", "if", "future", ".", "_ended", "(", ")", "and", "future", ".", "index", "is", "None", ":", "self", ".", "inprogress", ".", "add", "(", "future", ")", "elif", "future", ".", "_ended", "(", ")", ...
Append a future to the queue.
[ "Append", "a", "future", "to", "the", "queue", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_types.py#L299-L317
10,929
soravux/scoop
scoop/_types.py
FutureQueue.askForPreviousFutures
def askForPreviousFutures(self): """Request a status for every future to the broker.""" # Don't request it too often (otherwise it ping-pongs because) # the broker answer triggers the _poll of pop() if time.time() < self.lastStatus + POLLING_TIME / 1000: return self.l...
python
def askForPreviousFutures(self): """Request a status for every future to the broker.""" # Don't request it too often (otherwise it ping-pongs because) # the broker answer triggers the _poll of pop() if time.time() < self.lastStatus + POLLING_TIME / 1000: return self.l...
[ "def", "askForPreviousFutures", "(", "self", ")", ":", "# Don't request it too often (otherwise it ping-pongs because)", "# the broker answer triggers the _poll of pop()", "if", "time", ".", "time", "(", ")", "<", "self", ".", "lastStatus", "+", "POLLING_TIME", "/", "1000",...
Request a status for every future to the broker.
[ "Request", "a", "status", "for", "every", "future", "to", "the", "broker", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_types.py#L319-L333
10,930
soravux/scoop
scoop/_types.py
FutureQueue.pop
def pop(self): """Pop the next future from the queue; in progress futures have priority over those that have not yet started; higher level futures have priority over lower level ones; """ self.updateQueue() # If our buffer is underflowing, request more Futures if self.ti...
python
def pop(self): """Pop the next future from the queue; in progress futures have priority over those that have not yet started; higher level futures have priority over lower level ones; """ self.updateQueue() # If our buffer is underflowing, request more Futures if self.ti...
[ "def", "pop", "(", "self", ")", ":", "self", ".", "updateQueue", "(", ")", "# If our buffer is underflowing, request more Futures", "if", "self", ".", "timelen", "(", "self", ")", "<", "self", ".", "lowwatermark", ":", "self", ".", "requestFuture", "(", ")", ...
Pop the next future from the queue; in progress futures have priority over those that have not yet started; higher level futures have priority over lower level ones;
[ "Pop", "the", "next", "future", "from", "the", "queue", ";", "in", "progress", "futures", "have", "priority", "over", "those", "that", "have", "not", "yet", "started", ";", "higher", "level", "futures", "have", "priority", "over", "lower", "level", "ones", ...
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_types.py#L335-L363
10,931
soravux/scoop
scoop/_types.py
FutureQueue.flush
def flush(self): """Empty the local queue and send its elements to be executed remotely. """ for elem in self: if elem.id[0] != scoop.worker: elem._delete() self.socket.sendFuture(elem) self.ready.clear() self.movable.clear()
python
def flush(self): """Empty the local queue and send its elements to be executed remotely. """ for elem in self: if elem.id[0] != scoop.worker: elem._delete() self.socket.sendFuture(elem) self.ready.clear() self.movable.clear()
[ "def", "flush", "(", "self", ")", ":", "for", "elem", "in", "self", ":", "if", "elem", ".", "id", "[", "0", "]", "!=", "scoop", ".", "worker", ":", "elem", ".", "_delete", "(", ")", "self", ".", "socket", ".", "sendFuture", "(", "elem", ")", "s...
Empty the local queue and send its elements to be executed remotely.
[ "Empty", "the", "local", "queue", "and", "send", "its", "elements", "to", "be", "executed", "remotely", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_types.py#L365-L373
10,932
soravux/scoop
scoop/_types.py
FutureQueue.updateQueue
def updateQueue(self): """Process inbound communication buffer. Updates the local queue with elements from the broker.""" for future in self.socket.recvFuture(): if future._ended(): # If the answer is coming back, update its entry try: ...
python
def updateQueue(self): """Process inbound communication buffer. Updates the local queue with elements from the broker.""" for future in self.socket.recvFuture(): if future._ended(): # If the answer is coming back, update its entry try: ...
[ "def", "updateQueue", "(", "self", ")", ":", "for", "future", "in", "self", ".", "socket", ".", "recvFuture", "(", ")", ":", "if", "future", ".", "_ended", "(", ")", ":", "# If the answer is coming back, update its entry", "try", ":", "thisFuture", "=", "sco...
Process inbound communication buffer. Updates the local queue with elements from the broker.
[ "Process", "inbound", "communication", "buffer", ".", "Updates", "the", "local", "queue", "with", "elements", "from", "the", "broker", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_types.py#L379-L404
10,933
soravux/scoop
scoop/_types.py
FutureQueue.sendResult
def sendResult(self, future): """Send back results to broker for distribution to parent task.""" # Greenlets cannot be pickled future.greenlet = None assert future._ended(), "The results are not valid" self.socket.sendResult(future)
python
def sendResult(self, future): """Send back results to broker for distribution to parent task.""" # Greenlets cannot be pickled future.greenlet = None assert future._ended(), "The results are not valid" self.socket.sendResult(future)
[ "def", "sendResult", "(", "self", ",", "future", ")", ":", "# Greenlets cannot be pickled", "future", ".", "greenlet", "=", "None", "assert", "future", ".", "_ended", "(", ")", ",", "\"The results are not valid\"", "self", ".", "socket", ".", "sendResult", "(", ...
Send back results to broker for distribution to parent task.
[ "Send", "back", "results", "to", "broker", "for", "distribution", "to", "parent", "task", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_types.py#L411-L416
10,934
soravux/scoop
scoop/_types.py
FutureQueue.shutdown
def shutdown(self): """Shutdown the ressources used by the queue""" self.socket.shutdown() if scoop: if scoop.DEBUG: from scoop import _debug _debug.writeWorkerDebug( scoop._control.debug_stats, scoop._control.Q...
python
def shutdown(self): """Shutdown the ressources used by the queue""" self.socket.shutdown() if scoop: if scoop.DEBUG: from scoop import _debug _debug.writeWorkerDebug( scoop._control.debug_stats, scoop._control.Q...
[ "def", "shutdown", "(", "self", ")", ":", "self", ".", "socket", ".", "shutdown", "(", ")", "if", "scoop", ":", "if", "scoop", ".", "DEBUG", ":", "from", "scoop", "import", "_debug", "_debug", ".", "writeWorkerDebug", "(", "scoop", ".", "_control", "."...
Shutdown the ressources used by the queue
[ "Shutdown", "the", "ressources", "used", "by", "the", "queue" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_types.py#L418-L428
10,935
soravux/scoop
scoop/_debug.py
redirectSTDOUTtoDebugFile
def redirectSTDOUTtoDebugFile(): """Redirects the stdout and stderr of the current process to a file.""" import sys kwargs = {} if sys.version_info >= (3,): kwargs["encoding"] = "utf8" sys.stdout = open( os.path.join( getDebugDirectory(), "{0}.stdout".format(g...
python
def redirectSTDOUTtoDebugFile(): """Redirects the stdout and stderr of the current process to a file.""" import sys kwargs = {} if sys.version_info >= (3,): kwargs["encoding"] = "utf8" sys.stdout = open( os.path.join( getDebugDirectory(), "{0}.stdout".format(g...
[ "def", "redirectSTDOUTtoDebugFile", "(", ")", ":", "import", "sys", "kwargs", "=", "{", "}", "if", "sys", ".", "version_info", ">=", "(", "3", ",", ")", ":", "kwargs", "[", "\"encoding\"", "]", "=", "\"utf8\"", "sys", ".", "stdout", "=", "open", "(", ...
Redirects the stdout and stderr of the current process to a file.
[ "Redirects", "the", "stdout", "and", "stderr", "of", "the", "current", "process", "to", "a", "file", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_debug.py#L46-L69
10,936
soravux/scoop
scoop/_debug.py
writeWorkerDebug
def writeWorkerDebug(debugStats, queueLength, path_suffix=""): """Serialize the execution data using pickle and writes it into the debug directory.""" createDirectory(path_suffix) origin_prefix = "origin-" if scoop.IS_ORIGIN else "" statsFilename = os.path.join( getDebugDirectory(), ...
python
def writeWorkerDebug(debugStats, queueLength, path_suffix=""): """Serialize the execution data using pickle and writes it into the debug directory.""" createDirectory(path_suffix) origin_prefix = "origin-" if scoop.IS_ORIGIN else "" statsFilename = os.path.join( getDebugDirectory(), ...
[ "def", "writeWorkerDebug", "(", "debugStats", ",", "queueLength", ",", "path_suffix", "=", "\"\"", ")", ":", "createDirectory", "(", "path_suffix", ")", "origin_prefix", "=", "\"origin-\"", "if", "scoop", ".", "IS_ORIGIN", "else", "\"\"", "statsFilename", "=", "...
Serialize the execution data using pickle and writes it into the debug directory.
[ "Serialize", "the", "execution", "data", "using", "pickle", "and", "writes", "it", "into", "the", "debug", "directory", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_debug.py#L72-L90
10,937
soravux/scoop
scoop/launcher.py
main
def main(): """Execution of the SCOOP module. Parses its command-line arguments and launch needed resources.""" # Generate a argparse parser and parse the command-line arguments parser = makeParser() args = parser.parse_args() # Get a list of resources to launch worker(s) on hosts = utils.g...
python
def main(): """Execution of the SCOOP module. Parses its command-line arguments and launch needed resources.""" # Generate a argparse parser and parse the command-line arguments parser = makeParser() args = parser.parse_args() # Get a list of resources to launch worker(s) on hosts = utils.g...
[ "def", "main", "(", ")", ":", "# Generate a argparse parser and parse the command-line arguments", "parser", "=", "makeParser", "(", ")", "args", "=", "parser", ".", "parse_args", "(", ")", "# Get a list of resources to launch worker(s) on", "hosts", "=", "utils", ".", ...
Execution of the SCOOP module. Parses its command-line arguments and launch needed resources.
[ "Execution", "of", "the", "SCOOP", "module", ".", "Parses", "its", "command", "-", "line", "arguments", "and", "launch", "needed", "resources", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/launcher.py#L450-L499
10,938
soravux/scoop
scoop/launcher.py
ScoopApp.initLogging
def initLogging(self): """Configures the logger.""" verbose_levels = { 0: logging.WARNING, 1: logging.INFO, 2: logging.DEBUG, } logging.basicConfig( level=verbose_levels[self.verbose], format="[%(asctime)-15s] %(module)-9s %(lev...
python
def initLogging(self): """Configures the logger.""" verbose_levels = { 0: logging.WARNING, 1: logging.INFO, 2: logging.DEBUG, } logging.basicConfig( level=verbose_levels[self.verbose], format="[%(asctime)-15s] %(module)-9s %(lev...
[ "def", "initLogging", "(", "self", ")", ":", "verbose_levels", "=", "{", "0", ":", "logging", ".", "WARNING", ",", "1", ":", "logging", ".", "INFO", ",", "2", ":", "logging", ".", "DEBUG", ",", "}", "logging", ".", "basicConfig", "(", "level", "=", ...
Configures the logger.
[ "Configures", "the", "logger", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/launcher.py#L138-L149
10,939
soravux/scoop
scoop/launcher.py
ScoopApp.divideHosts
def divideHosts(self, hosts, qty): """Divide processes among hosts.""" maximumWorkers = sum(host[1] for host in hosts) # If specified amount of workers is greater than sum of each specified. if qty > maximumWorkers: index = 0 while qty > maximumWorkers: ...
python
def divideHosts(self, hosts, qty): """Divide processes among hosts.""" maximumWorkers = sum(host[1] for host in hosts) # If specified amount of workers is greater than sum of each specified. if qty > maximumWorkers: index = 0 while qty > maximumWorkers: ...
[ "def", "divideHosts", "(", "self", ",", "hosts", ",", "qty", ")", ":", "maximumWorkers", "=", "sum", "(", "host", "[", "1", "]", "for", "host", "in", "hosts", ")", "# If specified amount of workers is greater than sum of each specified.", "if", "qty", ">", "maxi...
Divide processes among hosts.
[ "Divide", "processes", "among", "hosts", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/launcher.py#L151-L185
10,940
soravux/scoop
scoop/launcher.py
ScoopApp.showHostDivision
def showHostDivision(self, headless): """Show the worker distribution over the hosts.""" scoop.logger.info('Worker d--istribution: ') for worker, number in self.worker_hosts: first_worker = (worker == self.worker_hosts[0][0]) scoop.logger.info(' {0}:\t{1} {2}'.format( ...
python
def showHostDivision(self, headless): """Show the worker distribution over the hosts.""" scoop.logger.info('Worker d--istribution: ') for worker, number in self.worker_hosts: first_worker = (worker == self.worker_hosts[0][0]) scoop.logger.info(' {0}:\t{1} {2}'.format( ...
[ "def", "showHostDivision", "(", "self", ",", "headless", ")", ":", "scoop", ".", "logger", ".", "info", "(", "'Worker d--istribution: '", ")", "for", "worker", ",", "number", "in", "self", ".", "worker_hosts", ":", "first_worker", "=", "(", "worker", "==", ...
Show the worker distribution over the hosts.
[ "Show", "the", "worker", "distribution", "over", "the", "hosts", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/launcher.py#L187-L197
10,941
soravux/scoop
scoop/launcher.py
ScoopApp.setWorkerInfo
def setWorkerInfo(self, hostname, workerAmount, origin): """Sets the worker information for the current host.""" scoop.logger.debug('Initialising {0}{1} worker {2} [{3}].'.format( "local" if hostname in utils.localHostnames else "remote", " origin" if origin else "", ...
python
def setWorkerInfo(self, hostname, workerAmount, origin): """Sets the worker information for the current host.""" scoop.logger.debug('Initialising {0}{1} worker {2} [{3}].'.format( "local" if hostname in utils.localHostnames else "remote", " origin" if origin else "", ...
[ "def", "setWorkerInfo", "(", "self", ",", "hostname", ",", "workerAmount", ",", "origin", ")", ":", "scoop", ".", "logger", ".", "debug", "(", "'Initialising {0}{1} worker {2} [{3}].'", ".", "format", "(", "\"local\"", "if", "hostname", "in", "utils", ".", "lo...
Sets the worker information for the current host.
[ "Sets", "the", "worker", "information", "for", "the", "current", "host", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/launcher.py#L228-L241
10,942
soravux/scoop
scoop/launcher.py
ScoopApp.close
def close(self): """Subprocess cleanup.""" # Give time to flush data if debug was on if self.debug: time.sleep(10) # Terminate workers for host in self.workers: host.close() # Terminate the brokers for broker in self.brokers: ...
python
def close(self): """Subprocess cleanup.""" # Give time to flush data if debug was on if self.debug: time.sleep(10) # Terminate workers for host in self.workers: host.close() # Terminate the brokers for broker in self.brokers: ...
[ "def", "close", "(", "self", ")", ":", "# Give time to flush data if debug was on", "if", "self", ".", "debug", ":", "time", ".", "sleep", "(", "10", ")", "# Terminate workers", "for", "host", "in", "self", ".", "workers", ":", "host", ".", "close", "(", "...
Subprocess cleanup.
[ "Subprocess", "cleanup", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/launcher.py#L320-L338
10,943
soravux/scoop
scoop/broker/brokerzmq.py
Broker.processConfig
def processConfig(self, worker_config): """Update the pool configuration with a worker configuration. """ self.config['headless'] |= worker_config.get("headless", False) if self.config['headless']: # Launch discovery process if not self.discovery_thread: ...
python
def processConfig(self, worker_config): """Update the pool configuration with a worker configuration. """ self.config['headless'] |= worker_config.get("headless", False) if self.config['headless']: # Launch discovery process if not self.discovery_thread: ...
[ "def", "processConfig", "(", "self", ",", "worker_config", ")", ":", "self", ".", "config", "[", "'headless'", "]", "|=", "worker_config", ".", "get", "(", "\"headless\"", ",", "False", ")", "if", "self", ".", "config", "[", "'headless'", "]", ":", "# La...
Update the pool configuration with a worker configuration.
[ "Update", "the", "pool", "configuration", "with", "a", "worker", "configuration", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/broker/brokerzmq.py#L173-L182
10,944
soravux/scoop
scoop/bootstrap/__main__.py
Bootstrap.main
def main(self): """Bootstrap an arbitrary script. If no agruments were passed, use discovery module to search and connect to a broker.""" if self.args is None: self.parse() self.log = utils.initLogging(self.verbose) # Change to the desired directory ...
python
def main(self): """Bootstrap an arbitrary script. If no agruments were passed, use discovery module to search and connect to a broker.""" if self.args is None: self.parse() self.log = utils.initLogging(self.verbose) # Change to the desired directory ...
[ "def", "main", "(", "self", ")", ":", "if", "self", ".", "args", "is", "None", ":", "self", ".", "parse", "(", ")", "self", ".", "log", "=", "utils", ".", "initLogging", "(", "self", ".", "verbose", ")", "# Change to the desired directory", "if", "self...
Bootstrap an arbitrary script. If no agruments were passed, use discovery module to search and connect to a broker.
[ "Bootstrap", "an", "arbitrary", "script", ".", "If", "no", "agruments", "were", "passed", "use", "discovery", "module", "to", "search", "and", "connect", "to", "a", "broker", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/bootstrap/__main__.py#L54-L92
10,945
soravux/scoop
scoop/bootstrap/__main__.py
Bootstrap.makeParser
def makeParser(self): """Generate the argparse parser object containing the bootloader accepted parameters """ self.parser = argparse.ArgumentParser(description='Starts the executable.', prog=("{0} -m scoop.bootstrap" ...
python
def makeParser(self): """Generate the argparse parser object containing the bootloader accepted parameters """ self.parser = argparse.ArgumentParser(description='Starts the executable.', prog=("{0} -m scoop.bootstrap" ...
[ "def", "makeParser", "(", "self", ")", ":", "self", ".", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Starts the executable.'", ",", "prog", "=", "(", "\"{0} -m scoop.bootstrap\"", ")", ".", "format", "(", "sys", ".", "executabl...
Generate the argparse parser object containing the bootloader accepted parameters
[ "Generate", "the", "argparse", "parser", "object", "containing", "the", "bootloader", "accepted", "parameters" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/bootstrap/__main__.py#L94-L150
10,946
soravux/scoop
scoop/bootstrap/__main__.py
Bootstrap.parse
def parse(self): """Generate a argparse parser and parse the command-line arguments""" if self.parser is None: self.makeParser() self.args = self.parser.parse_args() self.verbose = self.args.verbose
python
def parse(self): """Generate a argparse parser and parse the command-line arguments""" if self.parser is None: self.makeParser() self.args = self.parser.parse_args() self.verbose = self.args.verbose
[ "def", "parse", "(", "self", ")", ":", "if", "self", ".", "parser", "is", "None", ":", "self", ".", "makeParser", "(", ")", "self", ".", "args", "=", "self", ".", "parser", ".", "parse_args", "(", ")", "self", ".", "verbose", "=", "self", ".", "a...
Generate a argparse parser and parse the command-line arguments
[ "Generate", "a", "argparse", "parser", "and", "parse", "the", "command", "-", "line", "arguments" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/bootstrap/__main__.py#L152-L157
10,947
soravux/scoop
scoop/bootstrap/__main__.py
Bootstrap.setScoop
def setScoop(self): """Setup the SCOOP constants.""" scoop.IS_RUNNING = True scoop.IS_ORIGIN = self.args.origin scoop.BROKER = BrokerInfo( self.args.brokerHostname, self.args.taskPort, self.args.metaPort, self.args.externalBrokerHostname ...
python
def setScoop(self): """Setup the SCOOP constants.""" scoop.IS_RUNNING = True scoop.IS_ORIGIN = self.args.origin scoop.BROKER = BrokerInfo( self.args.brokerHostname, self.args.taskPort, self.args.metaPort, self.args.externalBrokerHostname ...
[ "def", "setScoop", "(", "self", ")", ":", "scoop", ".", "IS_RUNNING", "=", "True", "scoop", ".", "IS_ORIGIN", "=", "self", ".", "args", ".", "origin", "scoop", ".", "BROKER", "=", "BrokerInfo", "(", "self", ".", "args", ".", "brokerHostname", ",", "sel...
Setup the SCOOP constants.
[ "Setup", "the", "SCOOP", "constants", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/bootstrap/__main__.py#L159-L191
10,948
soravux/scoop
examples/shared_example.py
myFunc
def myFunc(parameter): """This function will be executed on the remote host even if it was not available at launch.""" print('Hello World from {0}!'.format(scoop.worker)) # It is possible to get a constant anywhere print(shared.getConst('myVar')[2]) # Parameters are handled as usual ret...
python
def myFunc(parameter): """This function will be executed on the remote host even if it was not available at launch.""" print('Hello World from {0}!'.format(scoop.worker)) # It is possible to get a constant anywhere print(shared.getConst('myVar')[2]) # Parameters are handled as usual ret...
[ "def", "myFunc", "(", "parameter", ")", ":", "print", "(", "'Hello World from {0}!'", ".", "format", "(", "scoop", ".", "worker", ")", ")", "# It is possible to get a constant anywhere", "print", "(", "shared", ".", "getConst", "(", "'myVar'", ")", "[", "2", "...
This function will be executed on the remote host even if it was not available at launch.
[ "This", "function", "will", "be", "executed", "on", "the", "remote", "host", "even", "if", "it", "was", "not", "available", "at", "launch", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/examples/shared_example.py#L26-L35
10,949
soravux/scoop
scoop/_comm/scooptcp.py
TCPCommunicator.sendResult
def sendResult(self, future): """Send a terminated future back to its parent.""" future = copy.copy(future) # Remove the (now) extraneous elements from future class future.callable = future.args = future.kargs = future.greenlet = None if not future.sendResultBack: ...
python
def sendResult(self, future): """Send a terminated future back to its parent.""" future = copy.copy(future) # Remove the (now) extraneous elements from future class future.callable = future.args = future.kargs = future.greenlet = None if not future.sendResultBack: ...
[ "def", "sendResult", "(", "self", ",", "future", ")", ":", "future", "=", "copy", ".", "copy", "(", "future", ")", "# Remove the (now) extraneous elements from future class\r", "future", ".", "callable", "=", "future", ".", "args", "=", "future", ".", "kargs", ...
Send a terminated future back to its parent.
[ "Send", "a", "terminated", "future", "back", "to", "its", "parent", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_comm/scooptcp.py#L315-L332
10,950
soravux/scoop
examples/url_fetch.py
getSize
def getSize(string): """ This functions opens a web sites and then calculate the total size of the page in bytes. This is for the sake of the example. Do not use this technique in real code as it is not a very bright way to do this.""" try: # We open the web page with urllib.request....
python
def getSize(string): """ This functions opens a web sites and then calculate the total size of the page in bytes. This is for the sake of the example. Do not use this technique in real code as it is not a very bright way to do this.""" try: # We open the web page with urllib.request....
[ "def", "getSize", "(", "string", ")", ":", "try", ":", "# We open the web page", "with", "urllib", ".", "request", ".", "urlopen", "(", "string", ",", "None", ",", "1", ")", "as", "f", ":", "return", "sum", "(", "len", "(", "line", ")", "for", "line"...
This functions opens a web sites and then calculate the total size of the page in bytes. This is for the sake of the example. Do not use this technique in real code as it is not a very bright way to do this.
[ "This", "functions", "opens", "a", "web", "sites", "and", "then", "calculate", "the", "total", "size", "of", "the", "page", "in", "bytes", ".", "This", "is", "for", "the", "sake", "of", "the", "example", ".", "Do", "not", "use", "this", "technique", "i...
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/examples/url_fetch.py#L30-L40
10,951
soravux/scoop
examples/shared_example_doc.py
getValue
def getValue(words): """Computes the sum of the values of the words.""" value = 0 for word in words: for letter in word: # shared.getConst will evaluate to the dictionary broadcasted by # the root Future value += shared.getConst('lettersValue')[letter] return ...
python
def getValue(words): """Computes the sum of the values of the words.""" value = 0 for word in words: for letter in word: # shared.getConst will evaluate to the dictionary broadcasted by # the root Future value += shared.getConst('lettersValue')[letter] return ...
[ "def", "getValue", "(", "words", ")", ":", "value", "=", "0", "for", "word", "in", "words", ":", "for", "letter", "in", "word", ":", "# shared.getConst will evaluate to the dictionary broadcasted by", "# the root Future", "value", "+=", "shared", ".", "getConst", ...
Computes the sum of the values of the words.
[ "Computes", "the", "sum", "of", "the", "values", "of", "the", "words", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/examples/shared_example_doc.py#L23-L31
10,952
soravux/scoop
scoop/backports/runpy.py
_run_module_code
def _run_module_code(code, init_globals=None, mod_name=None, mod_fname=None, mod_loader=None, pkg_name=None): """Helper to run code in new namespace with sys modified""" with _ModifiedArgv0(mod_fname): with _TempModule(mod_name) as temp_module: mod_glo...
python
def _run_module_code(code, init_globals=None, mod_name=None, mod_fname=None, mod_loader=None, pkg_name=None): """Helper to run code in new namespace with sys modified""" with _ModifiedArgv0(mod_fname): with _TempModule(mod_name) as temp_module: mod_glo...
[ "def", "_run_module_code", "(", "code", ",", "init_globals", "=", "None", ",", "mod_name", "=", "None", ",", "mod_fname", "=", "None", ",", "mod_loader", "=", "None", ",", "pkg_name", "=", "None", ")", ":", "with", "_ModifiedArgv0", "(", "mod_fname", ")", ...
Helper to run code in new namespace with sys modified
[ "Helper", "to", "run", "code", "in", "new", "namespace", "with", "sys", "modified" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/backports/runpy.py#L75-L86
10,953
soravux/scoop
scoop/backports/runpy.py
run_module
def run_module(mod_name, init_globals=None, run_name=None, alter_sys=False): """Execute a module's code without importing it Returns the resulting top level namespace dictionary """ mod_name, loader, code, fname = _get_module_details(mod_name) if run_name is None: run_name...
python
def run_module(mod_name, init_globals=None, run_name=None, alter_sys=False): """Execute a module's code without importing it Returns the resulting top level namespace dictionary """ mod_name, loader, code, fname = _get_module_details(mod_name) if run_name is None: run_name...
[ "def", "run_module", "(", "mod_name", ",", "init_globals", "=", "None", ",", "run_name", "=", "None", ",", "alter_sys", "=", "False", ")", ":", "mod_name", ",", "loader", ",", "code", ",", "fname", "=", "_get_module_details", "(", "mod_name", ")", "if", ...
Execute a module's code without importing it Returns the resulting top level namespace dictionary
[ "Execute", "a", "module", "s", "code", "without", "importing", "it" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/backports/runpy.py#L165-L181
10,954
soravux/scoop
scoop/backports/runpy.py
_get_importer
def _get_importer(path_name): """Python version of PyImport_GetImporter C API function""" cache = sys.path_importer_cache try: importer = cache[path_name] except KeyError: # Not yet cached. Flag as using the # standard machinery until we finish # checking the hooks ...
python
def _get_importer(path_name): """Python version of PyImport_GetImporter C API function""" cache = sys.path_importer_cache try: importer = cache[path_name] except KeyError: # Not yet cached. Flag as using the # standard machinery until we finish # checking the hooks ...
[ "def", "_get_importer", "(", "path_name", ")", ":", "cache", "=", "sys", ".", "path_importer_cache", "try", ":", "importer", "=", "cache", "[", "path_name", "]", "except", "KeyError", ":", "# Not yet cached. Flag as using the", "# standard machinery until we finish", ...
Python version of PyImport_GetImporter C API function
[ "Python", "version", "of", "PyImport_GetImporter", "C", "API", "function" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/backports/runpy.py#L186-L212
10,955
soravux/scoop
scoop/backports/runpy.py
run_path
def run_path(path_name, init_globals=None, run_name=None): """Execute code located at the specified filesystem location Returns the resulting top level namespace dictionary The file path may refer directly to a Python script (i.e. one that could be directly executed with execfile) or else ...
python
def run_path(path_name, init_globals=None, run_name=None): """Execute code located at the specified filesystem location Returns the resulting top level namespace dictionary The file path may refer directly to a Python script (i.e. one that could be directly executed with execfile) or else ...
[ "def", "run_path", "(", "path_name", ",", "init_globals", "=", "None", ",", "run_name", "=", "None", ")", ":", "if", "run_name", "is", "None", ":", "run_name", "=", "\"<run_path>\"", "importer", "=", "_get_importer", "(", "path_name", ")", "if", "isinstance"...
Execute code located at the specified filesystem location Returns the resulting top level namespace dictionary The file path may refer directly to a Python script (i.e. one that could be directly executed with execfile) or else it may refer to a zipfile or directory containing a top ...
[ "Execute", "code", "located", "at", "the", "specified", "filesystem", "location" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/backports/runpy.py#L224-L270
10,956
soravux/scoop
examples/tree_traversal.py
maxTreeDepthDivide
def maxTreeDepthDivide(rootValue, currentDepth=0, parallelLevel=2): """Finds a tree node that represents rootValue and computes the max depth of this tree branch. This function will emit new futures until currentDepth=parallelLevel""" thisRoot = shared.getConst('myTree').search(rootValue) if c...
python
def maxTreeDepthDivide(rootValue, currentDepth=0, parallelLevel=2): """Finds a tree node that represents rootValue and computes the max depth of this tree branch. This function will emit new futures until currentDepth=parallelLevel""" thisRoot = shared.getConst('myTree').search(rootValue) if c...
[ "def", "maxTreeDepthDivide", "(", "rootValue", ",", "currentDepth", "=", "0", ",", "parallelLevel", "=", "2", ")", ":", "thisRoot", "=", "shared", ".", "getConst", "(", "'myTree'", ")", ".", "search", "(", "rootValue", ")", "if", "currentDepth", ">=", "par...
Finds a tree node that represents rootValue and computes the max depth of this tree branch. This function will emit new futures until currentDepth=parallelLevel
[ "Finds", "a", "tree", "node", "that", "represents", "rootValue", "and", "computes", "the", "max", "depth", "of", "this", "tree", "branch", ".", "This", "function", "will", "emit", "new", "futures", "until", "currentDepth", "=", "parallelLevel" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/examples/tree_traversal.py#L27-L52
10,957
soravux/scoop
examples/tree_traversal.py
BinaryTreeNode.insert
def insert(self, value): """Insert a value in the tree""" if not self.payload or value == self.payload: self.payload = value else: if value <= self.payload: if self.left: self.left.insert(value) else: ...
python
def insert(self, value): """Insert a value in the tree""" if not self.payload or value == self.payload: self.payload = value else: if value <= self.payload: if self.left: self.left.insert(value) else: ...
[ "def", "insert", "(", "self", ",", "value", ")", ":", "if", "not", "self", ".", "payload", "or", "value", "==", "self", ".", "payload", ":", "self", ".", "payload", "=", "value", "else", ":", "if", "value", "<=", "self", ".", "payload", ":", "if", ...
Insert a value in the tree
[ "Insert", "a", "value", "in", "the", "tree" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/examples/tree_traversal.py#L62-L76
10,958
soravux/scoop
examples/tree_traversal.py
BinaryTreeNode.maxDepth
def maxDepth(self, currentDepth=0): """Compute the depth of the longest branch of the tree""" if not any((self.left, self.right)): return currentDepth result = 0 for child in (self.left, self.right): if child: result = max(result, child.maxDepth(cu...
python
def maxDepth(self, currentDepth=0): """Compute the depth of the longest branch of the tree""" if not any((self.left, self.right)): return currentDepth result = 0 for child in (self.left, self.right): if child: result = max(result, child.maxDepth(cu...
[ "def", "maxDepth", "(", "self", ",", "currentDepth", "=", "0", ")", ":", "if", "not", "any", "(", "(", "self", ".", "left", ",", "self", ".", "right", ")", ")", ":", "return", "currentDepth", "result", "=", "0", "for", "child", "in", "(", "self", ...
Compute the depth of the longest branch of the tree
[ "Compute", "the", "depth", "of", "the", "longest", "branch", "of", "the", "tree" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/examples/tree_traversal.py#L78-L86
10,959
soravux/scoop
examples/tree_traversal.py
BinaryTreeNode.search
def search(self, value): """Find an element in the tree""" if self.payload == value: return self else: if value <= self.payload: if self.left: return self.left.search(value) else: if self.right: ...
python
def search(self, value): """Find an element in the tree""" if self.payload == value: return self else: if value <= self.payload: if self.left: return self.left.search(value) else: if self.right: ...
[ "def", "search", "(", "self", ",", "value", ")", ":", "if", "self", ".", "payload", "==", "value", ":", "return", "self", "else", ":", "if", "value", "<=", "self", ".", "payload", ":", "if", "self", ".", "left", ":", "return", "self", ".", "left", ...
Find an element in the tree
[ "Find", "an", "element", "in", "the", "tree" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/examples/tree_traversal.py#L88-L99
10,960
soravux/scoop
scoop/_comm/scoopzmq.py
ZMQCommunicator.createZMQSocket
def createZMQSocket(self, sock_type): """Create a socket of the given sock_type and deactivate message dropping""" sock = self.ZMQcontext.socket(sock_type) sock.setsockopt(zmq.LINGER, LINGER_TIME) sock.setsockopt(zmq.IPV4ONLY, 0) # Remove message dropping sock.setsockopt...
python
def createZMQSocket(self, sock_type): """Create a socket of the given sock_type and deactivate message dropping""" sock = self.ZMQcontext.socket(sock_type) sock.setsockopt(zmq.LINGER, LINGER_TIME) sock.setsockopt(zmq.IPV4ONLY, 0) # Remove message dropping sock.setsockopt...
[ "def", "createZMQSocket", "(", "self", ",", "sock_type", ")", ":", "sock", "=", "self", ".", "ZMQcontext", ".", "socket", "(", "sock_type", ")", "sock", ".", "setsockopt", "(", "zmq", ".", "LINGER", ",", "LINGER_TIME", ")", "sock", ".", "setsockopt", "("...
Create a socket of the given sock_type and deactivate message dropping
[ "Create", "a", "socket", "of", "the", "given", "sock_type", "and", "deactivate", "message", "dropping" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_comm/scoopzmq.py#L164-L182
10,961
soravux/scoop
scoop/_comm/scoopzmq.py
ZMQCommunicator._reportFutures
def _reportFutures(self): """Sends futures status updates to broker at intervals of scoop.TIME_BETWEEN_STATUS_REPORTS seconds. Is intended to be run by a separate thread.""" try: while True: time.sleep(scoop.TIME_BETWEEN_STATUS_REPORTS) fids = ...
python
def _reportFutures(self): """Sends futures status updates to broker at intervals of scoop.TIME_BETWEEN_STATUS_REPORTS seconds. Is intended to be run by a separate thread.""" try: while True: time.sleep(scoop.TIME_BETWEEN_STATUS_REPORTS) fids = ...
[ "def", "_reportFutures", "(", "self", ")", ":", "try", ":", "while", "True", ":", "time", ".", "sleep", "(", "scoop", ".", "TIME_BETWEEN_STATUS_REPORTS", ")", "fids", "=", "set", "(", "x", ".", "id", "for", "x", "in", "scoop", ".", "_control", ".", "...
Sends futures status updates to broker at intervals of scoop.TIME_BETWEEN_STATUS_REPORTS seconds. Is intended to be run by a separate thread.
[ "Sends", "futures", "status", "updates", "to", "broker", "at", "intervals", "of", "scoop", ".", "TIME_BETWEEN_STATUS_REPORTS", "seconds", ".", "Is", "intended", "to", "be", "run", "by", "a", "separate", "thread", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_comm/scoopzmq.py#L184-L200
10,962
soravux/scoop
scoop/_comm/scoopzmq.py
ZMQCommunicator._sendReply
def _sendReply(self, destination, fid, *args): """Send a REPLY directly to its destination. If it doesn't work, launch it back to the broker.""" # Try to send the result directly to its parent self.addPeer(destination) try: self.direct_socket.send_multipart([ ...
python
def _sendReply(self, destination, fid, *args): """Send a REPLY directly to its destination. If it doesn't work, launch it back to the broker.""" # Try to send the result directly to its parent self.addPeer(destination) try: self.direct_socket.send_multipart([ ...
[ "def", "_sendReply", "(", "self", ",", "destination", ",", "fid", ",", "*", "args", ")", ":", "# Try to send the result directly to its parent", "self", ".", "addPeer", "(", "destination", ")", "try", ":", "self", ".", "direct_socket", ".", "send_multipart", "("...
Send a REPLY directly to its destination. If it doesn't work, launch it back to the broker.
[ "Send", "a", "REPLY", "directly", "to", "its", "destination", ".", "If", "it", "doesn", "t", "work", "launch", "it", "back", "to", "the", "broker", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_comm/scoopzmq.py#L399-L426
10,963
soravux/scoop
scoop/futures.py
_startup
def _startup(rootFuture, *args, **kargs): """Initializes the SCOOP environment. :param rootFuture: Any callable object (function or class object with *__call__* method); this object will be called once and allows the use of parallel calls inside this object. :param args: A tuple of position...
python
def _startup(rootFuture, *args, **kargs): """Initializes the SCOOP environment. :param rootFuture: Any callable object (function or class object with *__call__* method); this object will be called once and allows the use of parallel calls inside this object. :param args: A tuple of position...
[ "def", "_startup", "(", "rootFuture", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "import", "greenlet", "global", "_controller", "_controller", "=", "greenlet", ".", "greenlet", "(", "control", ".", "runController", ")", "try", ":", "result", "=", ...
Initializes the SCOOP environment. :param rootFuture: Any callable object (function or class object with *__call__* method); this object will be called once and allows the use of parallel calls inside this object. :param args: A tuple of positional arguments that will be passed to the c...
[ "Initializes", "the", "SCOOP", "environment", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/futures.py#L47-L69
10,964
soravux/scoop
scoop/futures.py
_recursiveReduce
def _recursiveReduce(mapFunc, reductionFunc, scan, *iterables): """Generates the recursive reduction tree. Used by mapReduce.""" if iterables: half = min(len(x) // 2 for x in iterables) data_left = [list(x)[:half] for x in iterables] data_right = [list(x)[half:] for x in iterables] e...
python
def _recursiveReduce(mapFunc, reductionFunc, scan, *iterables): """Generates the recursive reduction tree. Used by mapReduce.""" if iterables: half = min(len(x) // 2 for x in iterables) data_left = [list(x)[:half] for x in iterables] data_right = [list(x)[half:] for x in iterables] e...
[ "def", "_recursiveReduce", "(", "mapFunc", ",", "reductionFunc", ",", "scan", ",", "*", "iterables", ")", ":", "if", "iterables", ":", "half", "=", "min", "(", "len", "(", "x", ")", "//", "2", "for", "x", "in", "iterables", ")", "data_left", "=", "["...
Generates the recursive reduction tree. Used by mapReduce.
[ "Generates", "the", "recursive", "reduction", "tree", ".", "Used", "by", "mapReduce", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/futures.py#L154-L196
10,965
soravux/scoop
scoop/futures.py
_createFuture
def _createFuture(func, *args, **kwargs): """Helper function to create a future.""" assert callable(func), ( "The provided func parameter is not a callable." ) if scoop.IS_ORIGIN and "SCOOP_WORKER" not in sys.modules: sys.modules["SCOOP_WORKER"] = sys.modules["__main__"] # If funct...
python
def _createFuture(func, *args, **kwargs): """Helper function to create a future.""" assert callable(func), ( "The provided func parameter is not a callable." ) if scoop.IS_ORIGIN and "SCOOP_WORKER" not in sys.modules: sys.modules["SCOOP_WORKER"] = sys.modules["__main__"] # If funct...
[ "def", "_createFuture", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "assert", "callable", "(", "func", ")", ",", "(", "\"The provided func parameter is not a callable.\"", ")", "if", "scoop", ".", "IS_ORIGIN", "and", "\"SCOOP_WORKER\"", "...
Helper function to create a future.
[ "Helper", "function", "to", "create", "a", "future", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/futures.py#L259-L279
10,966
soravux/scoop
scoop/futures.py
_waitAny
def _waitAny(*children): """Waits on any child Future created by the calling Future. :param children: A tuple of children Future objects spawned by the calling Future. :return: A generator function that iterates on futures that are done. The generator produces results of the children in a non...
python
def _waitAny(*children): """Waits on any child Future created by the calling Future. :param children: A tuple of children Future objects spawned by the calling Future. :return: A generator function that iterates on futures that are done. The generator produces results of the children in a non...
[ "def", "_waitAny", "(", "*", "children", ")", ":", "n", "=", "len", "(", "children", ")", "# check for available results and index those unavailable", "for", "index", ",", "future", "in", "enumerate", "(", "children", ")", ":", "if", "future", ".", "exceptionVal...
Waits on any child Future created by the calling Future. :param children: A tuple of children Future objects spawned by the calling Future. :return: A generator function that iterates on futures that are done. The generator produces results of the children in a non deterministic order that de...
[ "Waits", "on", "any", "child", "Future", "created", "by", "the", "calling", "Future", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/futures.py#L308-L342
10,967
soravux/scoop
scoop/futures.py
wait
def wait(fs, timeout=-1, return_when=ALL_COMPLETED): """Wait for the futures in the given sequence to complete. Using this function may prevent a worker from executing. :param fs: The sequence of Futures to wait upon. :param timeout: The maximum number of seconds to wait. If negative or not spe...
python
def wait(fs, timeout=-1, return_when=ALL_COMPLETED): """Wait for the futures in the given sequence to complete. Using this function may prevent a worker from executing. :param fs: The sequence of Futures to wait upon. :param timeout: The maximum number of seconds to wait. If negative or not spe...
[ "def", "wait", "(", "fs", ",", "timeout", "=", "-", "1", ",", "return_when", "=", "ALL_COMPLETED", ")", ":", "DoneAndNotDoneFutures", "=", "namedtuple", "(", "'DoneAndNotDoneFutures'", ",", "'done not_done'", ")", "if", "timeout", "<", "0", ":", "# Negative ti...
Wait for the futures in the given sequence to complete. Using this function may prevent a worker from executing. :param fs: The sequence of Futures to wait upon. :param timeout: The maximum number of seconds to wait. If negative or not specified, then there is no limit on the wait time. :param ...
[ "Wait", "for", "the", "futures", "in", "the", "given", "sequence", "to", "complete", ".", "Using", "this", "function", "may", "prevent", "a", "worker", "from", "executing", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/futures.py#L364-L429
10,968
soravux/scoop
scoop/_control.py
advertiseBrokerWorkerDown
def advertiseBrokerWorkerDown(exctype, value, traceback): """Hook advertizing the broker if an impromptu shutdown is occuring.""" if not scoop.SHUTDOWN_REQUESTED: execQueue.shutdown() sys.__excepthook__(exctype, value, traceback)
python
def advertiseBrokerWorkerDown(exctype, value, traceback): """Hook advertizing the broker if an impromptu shutdown is occuring.""" if not scoop.SHUTDOWN_REQUESTED: execQueue.shutdown() sys.__excepthook__(exctype, value, traceback)
[ "def", "advertiseBrokerWorkerDown", "(", "exctype", ",", "value", ",", "traceback", ")", ":", "if", "not", "scoop", ".", "SHUTDOWN_REQUESTED", ":", "execQueue", ".", "shutdown", "(", ")", "sys", ".", "__excepthook__", "(", "exctype", ",", "value", ",", "trac...
Hook advertizing the broker if an impromptu shutdown is occuring.
[ "Hook", "advertizing", "the", "broker", "if", "an", "impromptu", "shutdown", "is", "occuring", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_control.py#L91-L95
10,969
soravux/scoop
scoop/_control.py
delFutureById
def delFutureById(futureId, parentId): """Delete future on id basis""" try: del futureDict[futureId] except KeyError: pass try: toDel = [a for a in futureDict[parentId].children if a.id == futureId] for f in toDel: del futureDict[parentId].children[f] exce...
python
def delFutureById(futureId, parentId): """Delete future on id basis""" try: del futureDict[futureId] except KeyError: pass try: toDel = [a for a in futureDict[parentId].children if a.id == futureId] for f in toDel: del futureDict[parentId].children[f] exce...
[ "def", "delFutureById", "(", "futureId", ",", "parentId", ")", ":", "try", ":", "del", "futureDict", "[", "futureId", "]", "except", "KeyError", ":", "pass", "try", ":", "toDel", "=", "[", "a", "for", "a", "in", "futureDict", "[", "parentId", "]", ".",...
Delete future on id basis
[ "Delete", "future", "on", "id", "basis" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_control.py#L108-L119
10,970
soravux/scoop
scoop/_control.py
delFuture
def delFuture(afuture): """Delete future afuture""" try: del futureDict[afuture.id] except KeyError: pass try: del futureDict[afuture.parentId].children[afuture] except KeyError: pass
python
def delFuture(afuture): """Delete future afuture""" try: del futureDict[afuture.id] except KeyError: pass try: del futureDict[afuture.parentId].children[afuture] except KeyError: pass
[ "def", "delFuture", "(", "afuture", ")", ":", "try", ":", "del", "futureDict", "[", "afuture", ".", "id", "]", "except", "KeyError", ":", "pass", "try", ":", "del", "futureDict", "[", "afuture", ".", "parentId", "]", ".", "children", "[", "afuture", "]...
Delete future afuture
[ "Delete", "future", "afuture" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_control.py#L122-L131
10,971
soravux/scoop
scoop/_control.py
runFuture
def runFuture(future): """Callable greenlet in charge of running tasks.""" global debug_stats global QueueLength if scoop.DEBUG: init_debug() # in case _control is imported before scoop.DEBUG was set debug_stats[future.id]['start_time'].append(time.time()) future.waitTime = future.s...
python
def runFuture(future): """Callable greenlet in charge of running tasks.""" global debug_stats global QueueLength if scoop.DEBUG: init_debug() # in case _control is imported before scoop.DEBUG was set debug_stats[future.id]['start_time'].append(time.time()) future.waitTime = future.s...
[ "def", "runFuture", "(", "future", ")", ":", "global", "debug_stats", "global", "QueueLength", "if", "scoop", ".", "DEBUG", ":", "init_debug", "(", ")", "# in case _control is imported before scoop.DEBUG was set", "debug_stats", "[", "future", ".", "id", "]", "[", ...
Callable greenlet in charge of running tasks.
[ "Callable", "greenlet", "in", "charge", "of", "running", "tasks", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_control.py#L134-L187
10,972
soravux/scoop
scoop/_control.py
runController
def runController(callable_, *args, **kargs): """Callable greenlet implementing controller logic.""" global execQueue # initialize and run root future rootId = (-1, 0) # initialise queue if execQueue is None: execQueue = FutureQueue() sys.excepthook = advertiseBrokerWorkerDown...
python
def runController(callable_, *args, **kargs): """Callable greenlet implementing controller logic.""" global execQueue # initialize and run root future rootId = (-1, 0) # initialise queue if execQueue is None: execQueue = FutureQueue() sys.excepthook = advertiseBrokerWorkerDown...
[ "def", "runController", "(", "callable_", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "global", "execQueue", "# initialize and run root future", "rootId", "=", "(", "-", "1", ",", "0", ")", "# initialise queue", "if", "execQueue", "is", "None", ":", ...
Callable greenlet implementing controller logic.
[ "Callable", "greenlet", "implementing", "controller", "logic", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_control.py#L190-L287
10,973
soravux/scoop
scoop/_control.py
_stat.mode
def mode(self): """Computes the mode of a log-normal distribution built with the stats data.""" mu = self.mean() sigma = self.std() ret_val = math.exp(mu - sigma**2) if math.isnan(ret_val): ret_val = float("inf") return ret_val
python
def mode(self): """Computes the mode of a log-normal distribution built with the stats data.""" mu = self.mean() sigma = self.std() ret_val = math.exp(mu - sigma**2) if math.isnan(ret_val): ret_val = float("inf") return ret_val
[ "def", "mode", "(", "self", ")", ":", "mu", "=", "self", ".", "mean", "(", ")", "sigma", "=", "self", ".", "std", "(", ")", "ret_val", "=", "math", ".", "exp", "(", "mu", "-", "sigma", "**", "2", ")", "if", "math", ".", "isnan", "(", "ret_val...
Computes the mode of a log-normal distribution built with the stats data.
[ "Computes", "the", "mode", "of", "a", "log", "-", "normal", "distribution", "built", "with", "the", "stats", "data", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_control.py#L73-L80
10,974
soravux/scoop
scoop/_control.py
_stat.median
def median(self): """Computes the median of a log-normal distribution built with the stats data.""" mu = self.mean() ret_val = math.exp(mu) if math.isnan(ret_val): ret_val = float("inf") return ret_val
python
def median(self): """Computes the median of a log-normal distribution built with the stats data.""" mu = self.mean() ret_val = math.exp(mu) if math.isnan(ret_val): ret_val = float("inf") return ret_val
[ "def", "median", "(", "self", ")", ":", "mu", "=", "self", ".", "mean", "(", ")", "ret_val", "=", "math", ".", "exp", "(", "mu", ")", "if", "math", ".", "isnan", "(", "ret_val", ")", ":", "ret_val", "=", "float", "(", "\"inf\"", ")", "return", ...
Computes the median of a log-normal distribution built with the stats data.
[ "Computes", "the", "median", "of", "a", "log", "-", "normal", "distribution", "built", "with", "the", "stats", "data", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_control.py#L82-L88
10,975
soravux/scoop
scoop/discovery/minusconf.py
_decode_string
def _decode_string(buf, pos): """ Decodes a string in the buffer buf, starting at position pos. Returns a tupel of the read string and the next byte to read. """ for i in range(pos, len(buf)): if buf[i:i+1] == _compat_bytes('\x00'): try: return (buf[pos:i].decode(_CHA...
python
def _decode_string(buf, pos): """ Decodes a string in the buffer buf, starting at position pos. Returns a tupel of the read string and the next byte to read. """ for i in range(pos, len(buf)): if buf[i:i+1] == _compat_bytes('\x00'): try: return (buf[pos:i].decode(_CHA...
[ "def", "_decode_string", "(", "buf", ",", "pos", ")", ":", "for", "i", "in", "range", "(", "pos", ",", "len", "(", "buf", ")", ")", ":", "if", "buf", "[", "i", ":", "i", "+", "1", "]", "==", "_compat_bytes", "(", "'\\x00'", ")", ":", "try", "...
Decodes a string in the buffer buf, starting at position pos. Returns a tupel of the read string and the next byte to read.
[ "Decodes", "a", "string", "in", "the", "buffer", "buf", "starting", "at", "position", "pos", ".", "Returns", "a", "tupel", "of", "the", "read", "string", "and", "the", "next", "byte", "to", "read", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/discovery/minusconf.py#L492-L506
10,976
soravux/scoop
scoop/discovery/minusconf.py
_find_sock
def _find_sock(): """ Create a UDP socket """ if socket.has_ipv6: try: return socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) except socket.gaierror: pass # Platform lied about IPv6 support return socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
python
def _find_sock(): """ Create a UDP socket """ if socket.has_ipv6: try: return socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) except socket.gaierror: pass # Platform lied about IPv6 support return socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
[ "def", "_find_sock", "(", ")", ":", "if", "socket", ".", "has_ipv6", ":", "try", ":", "return", "socket", ".", "socket", "(", "socket", ".", "AF_INET6", ",", "socket", ".", "SOCK_DGRAM", ")", "except", "socket", ".", "gaierror", ":", "pass", "# Platform ...
Create a UDP socket
[ "Create", "a", "UDP", "socket" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/discovery/minusconf.py#L556-L563
10,977
soravux/scoop
scoop/discovery/minusconf.py
_compat_inet_pton
def _compat_inet_pton(family, addr): """ socket.inet_pton for platforms that don't have it """ if family == socket.AF_INET: # inet_aton accepts some strange forms, so we use our own res = _compat_bytes('') parts = addr.split('.') if len(parts) != 4: raise ValueError(...
python
def _compat_inet_pton(family, addr): """ socket.inet_pton for platforms that don't have it """ if family == socket.AF_INET: # inet_aton accepts some strange forms, so we use our own res = _compat_bytes('') parts = addr.split('.') if len(parts) != 4: raise ValueError(...
[ "def", "_compat_inet_pton", "(", "family", ",", "addr", ")", ":", "if", "family", "==", "socket", ".", "AF_INET", ":", "# inet_aton accepts some strange forms, so we use our own", "res", "=", "_compat_bytes", "(", "''", ")", "parts", "=", "addr", ".", "split", "...
socket.inet_pton for platforms that don't have it
[ "socket", ".", "inet_pton", "for", "platforms", "that", "don", "t", "have", "it" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/discovery/minusconf.py#L623-L688
10,978
soravux/scoop
scoop/discovery/minusconf.py
ConcurrentAdvertiser.start_blocking
def start_blocking(self): """ Start the advertiser in the background, but wait until it is ready """ self._cav_started.clear() self.start() self._cav_started.wait()
python
def start_blocking(self): """ Start the advertiser in the background, but wait until it is ready """ self._cav_started.clear() self.start() self._cav_started.wait()
[ "def", "start_blocking", "(", "self", ")", ":", "self", ".", "_cav_started", ".", "clear", "(", ")", "self", ".", "start", "(", ")", "self", ".", "_cav_started", ".", "wait", "(", ")" ]
Start the advertiser in the background, but wait until it is ready
[ "Start", "the", "advertiser", "in", "the", "background", "but", "wait", "until", "it", "is", "ready" ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/discovery/minusconf.py#L243-L248
10,979
soravux/scoop
scoop/discovery/minusconf.py
Seeker._send_queries
def _send_queries(self): """ Sends queries to multiple addresses. Returns the number of successful queries. """ res = 0 addrs = _resolve_addrs(self.addresses, self.port, self.ignore_senderrors, [self._sock.family]) for addr in addrs: try: self._send_query(ad...
python
def _send_queries(self): """ Sends queries to multiple addresses. Returns the number of successful queries. """ res = 0 addrs = _resolve_addrs(self.addresses, self.port, self.ignore_senderrors, [self._sock.family]) for addr in addrs: try: self._send_query(ad...
[ "def", "_send_queries", "(", "self", ")", ":", "res", "=", "0", "addrs", "=", "_resolve_addrs", "(", "self", ".", "addresses", ",", "self", ".", "port", ",", "self", ".", "ignore_senderrors", ",", "[", "self", ".", "_sock", ".", "family", "]", ")", "...
Sends queries to multiple addresses. Returns the number of successful queries.
[ "Sends", "queries", "to", "multiple", "addresses", ".", "Returns", "the", "number", "of", "successful", "queries", "." ]
d391dfa62f47e49d48328ee9cf08aa114256fd33
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/discovery/minusconf.py#L383-L397
10,980
dmpayton/django-admin-honeypot
admin_honeypot/forms.py
HoneypotLoginForm.clean
def clean(self): """ Always raise the default error message, because we don't care what they entered here. """ raise forms.ValidationError( self.error_messages['invalid_login'], code='invalid_login', params={'username': self.username_field.verb...
python
def clean(self): """ Always raise the default error message, because we don't care what they entered here. """ raise forms.ValidationError( self.error_messages['invalid_login'], code='invalid_login', params={'username': self.username_field.verb...
[ "def", "clean", "(", "self", ")", ":", "raise", "forms", ".", "ValidationError", "(", "self", ".", "error_messages", "[", "'invalid_login'", "]", ",", "code", "=", "'invalid_login'", ",", "params", "=", "{", "'username'", ":", "self", ".", "username_field", ...
Always raise the default error message, because we don't care what they entered here.
[ "Always", "raise", "the", "default", "error", "message", "because", "we", "don", "t", "care", "what", "they", "entered", "here", "." ]
1308e5f794cd3b3b3c517e0ed96070bb1d656ce3
https://github.com/dmpayton/django-admin-honeypot/blob/1308e5f794cd3b3b3c517e0ed96070bb1d656ce3/admin_honeypot/forms.py#L7-L16
10,981
deadpixi/contracts
dpcontracts.py
types
def types(**requirements): """ Specify a precondition based on the types of the function's arguments. """ def predicate(args): for name, kind in sorted(requirements.items()): assert hasattr(args, name), "missing required argument `%s`" % name if not isinstance(kind,...
python
def types(**requirements): """ Specify a precondition based on the types of the function's arguments. """ def predicate(args): for name, kind in sorted(requirements.items()): assert hasattr(args, name), "missing required argument `%s`" % name if not isinstance(kind,...
[ "def", "types", "(", "*", "*", "requirements", ")", ":", "def", "predicate", "(", "args", ")", ":", "for", "name", ",", "kind", "in", "sorted", "(", "requirements", ".", "items", "(", ")", ")", ":", "assert", "hasattr", "(", "args", ",", "name", ")...
Specify a precondition based on the types of the function's arguments.
[ "Specify", "a", "precondition", "based", "on", "the", "types", "of", "the", "function", "s", "arguments", "." ]
45cb8542272c2ebe095c6efb97aa9407ddc8bf3c
https://github.com/deadpixi/contracts/blob/45cb8542272c2ebe095c6efb97aa9407ddc8bf3c/dpcontracts.py#L701-L719
10,982
deadpixi/contracts
dpcontracts.py
ensure
def ensure(arg1, arg2=None): """ Specify a precondition described by `description` and tested by `predicate`. """ assert (isinstance(arg1, str) and isfunction(arg2)) or (isfunction(arg1) and arg2 is None) description = "" predicate = lambda x: x if isinstance(arg1, str): descr...
python
def ensure(arg1, arg2=None): """ Specify a precondition described by `description` and tested by `predicate`. """ assert (isinstance(arg1, str) and isfunction(arg2)) or (isfunction(arg1) and arg2 is None) description = "" predicate = lambda x: x if isinstance(arg1, str): descr...
[ "def", "ensure", "(", "arg1", ",", "arg2", "=", "None", ")", ":", "assert", "(", "isinstance", "(", "arg1", ",", "str", ")", "and", "isfunction", "(", "arg2", ")", ")", "or", "(", "isfunction", "(", "arg1", ")", "and", "arg2", "is", "None", ")", ...
Specify a precondition described by `description` and tested by `predicate`.
[ "Specify", "a", "precondition", "described", "by", "description", "and", "tested", "by", "predicate", "." ]
45cb8542272c2ebe095c6efb97aa9407ddc8bf3c
https://github.com/deadpixi/contracts/blob/45cb8542272c2ebe095c6efb97aa9407ddc8bf3c/dpcontracts.py#L721-L739
10,983
deadpixi/contracts
dpcontracts.py
invariant
def invariant(arg1, arg2=None): """ Specify a class invariant described by `description` and tested by `predicate`. """ desc = "" predicate = lambda x: x if isinstance(arg1, str): desc = arg1 predicate = arg2 else: desc = get_function_source(arg1) predic...
python
def invariant(arg1, arg2=None): """ Specify a class invariant described by `description` and tested by `predicate`. """ desc = "" predicate = lambda x: x if isinstance(arg1, str): desc = arg1 predicate = arg2 else: desc = get_function_source(arg1) predic...
[ "def", "invariant", "(", "arg1", ",", "arg2", "=", "None", ")", ":", "desc", "=", "\"\"", "predicate", "=", "lambda", "x", ":", "x", "if", "isinstance", "(", "arg1", ",", "str", ")", ":", "desc", "=", "arg1", "predicate", "=", "arg2", "else", ":", ...
Specify a class invariant described by `description` and tested by `predicate`.
[ "Specify", "a", "class", "invariant", "described", "by", "description", "and", "tested", "by", "predicate", "." ]
45cb8542272c2ebe095c6efb97aa9407ddc8bf3c
https://github.com/deadpixi/contracts/blob/45cb8542272c2ebe095c6efb97aa9407ddc8bf3c/dpcontracts.py#L741-L781
10,984
Gandi/gandi.cli
gandi/cli/core/utils/password.py
mkpassword
def mkpassword(length=16, chars=None, punctuation=None): """Generates a random ascii string - useful to generate authinfos :param length: string wanted length :type length: ``int`` :param chars: character population, defaults to alphabet (lower & upper) + numbers :type chars: ``s...
python
def mkpassword(length=16, chars=None, punctuation=None): """Generates a random ascii string - useful to generate authinfos :param length: string wanted length :type length: ``int`` :param chars: character population, defaults to alphabet (lower & upper) + numbers :type chars: ``s...
[ "def", "mkpassword", "(", "length", "=", "16", ",", "chars", "=", "None", ",", "punctuation", "=", "None", ")", ":", "if", "chars", "is", "None", ":", "chars", "=", "string", ".", "ascii_letters", "+", "string", ".", "digits", "# Generate string from popul...
Generates a random ascii string - useful to generate authinfos :param length: string wanted length :type length: ``int`` :param chars: character population, defaults to alphabet (lower & upper) + numbers :type chars: ``str``, ``list``, ``set`` (sequence) :param punctuation: numb...
[ "Generates", "a", "random", "ascii", "string", "-", "useful", "to", "generate", "authinfos" ]
6ee5b8fc8ec44b0a6c232043ca610606ad8f693d
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/utils/password.py#L12-L44
10,985
Gandi/gandi.cli
gandi/cli/core/utils/size.py
disk_check_size
def disk_check_size(ctx, param, value): """ Validation callback for disk size parameter.""" if value: # if we've got a prefix if isinstance(value, tuple): val = value[1] else: val = value if val % 1024: raise click.ClickException('Size must be ...
python
def disk_check_size(ctx, param, value): """ Validation callback for disk size parameter.""" if value: # if we've got a prefix if isinstance(value, tuple): val = value[1] else: val = value if val % 1024: raise click.ClickException('Size must be ...
[ "def", "disk_check_size", "(", "ctx", ",", "param", ",", "value", ")", ":", "if", "value", ":", "# if we've got a prefix", "if", "isinstance", "(", "value", ",", "tuple", ")", ":", "val", "=", "value", "[", "1", "]", "else", ":", "val", "=", "value", ...
Validation callback for disk size parameter.
[ "Validation", "callback", "for", "disk", "size", "parameter", "." ]
6ee5b8fc8ec44b0a6c232043ca610606ad8f693d
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/utils/size.py#L8-L18
10,986
Gandi/gandi.cli
gandi/cli/modules/dnssec.py
DNSSEC.create
def create(cls, fqdn, flags, algorithm, public_key): """Create a dnssec key.""" fqdn = fqdn.lower() params = { 'flags': flags, 'algorithm': algorithm, 'public_key': public_key, } result = cls.call('domain.dnssec.create', fqdn, params) ...
python
def create(cls, fqdn, flags, algorithm, public_key): """Create a dnssec key.""" fqdn = fqdn.lower() params = { 'flags': flags, 'algorithm': algorithm, 'public_key': public_key, } result = cls.call('domain.dnssec.create', fqdn, params) ...
[ "def", "create", "(", "cls", ",", "fqdn", ",", "flags", ",", "algorithm", ",", "public_key", ")", ":", "fqdn", "=", "fqdn", ".", "lower", "(", ")", "params", "=", "{", "'flags'", ":", "flags", ",", "'algorithm'", ":", "algorithm", ",", "'public_key'", ...
Create a dnssec key.
[ "Create", "a", "dnssec", "key", "." ]
6ee5b8fc8ec44b0a6c232043ca610606ad8f693d
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/dnssec.py#L22-L34
10,987
Gandi/gandi.cli
gandi/cli/modules/snapshotprofile.py
SnapshotProfile.from_name
def from_name(cls, name): """ Retrieve a snapshot profile accsociated to a name.""" snps = cls.list({'name': name}) if len(snps) == 1: return snps[0]['id'] elif not snps: return raise DuplicateResults('snapshot profile name %s is ambiguous.' % name)
python
def from_name(cls, name): """ Retrieve a snapshot profile accsociated to a name.""" snps = cls.list({'name': name}) if len(snps) == 1: return snps[0]['id'] elif not snps: return raise DuplicateResults('snapshot profile name %s is ambiguous.' % name)
[ "def", "from_name", "(", "cls", ",", "name", ")", ":", "snps", "=", "cls", ".", "list", "(", "{", "'name'", ":", "name", "}", ")", "if", "len", "(", "snps", ")", "==", "1", ":", "return", "snps", "[", "0", "]", "[", "'id'", "]", "elif", "not"...
Retrieve a snapshot profile accsociated to a name.
[ "Retrieve", "a", "snapshot", "profile", "accsociated", "to", "a", "name", "." ]
6ee5b8fc8ec44b0a6c232043ca610606ad8f693d
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/snapshotprofile.py#L17-L25
10,988
Gandi/gandi.cli
gandi/cli/modules/snapshotprofile.py
SnapshotProfile.list
def list(cls, options=None, target=None): """ List all snapshot profiles.""" options = options or {} result = [] if not target or target == 'paas': for profile in cls.safe_call('paas.snapshotprofile.list', options): profile['target'] = 'paas' ...
python
def list(cls, options=None, target=None): """ List all snapshot profiles.""" options = options or {} result = [] if not target or target == 'paas': for profile in cls.safe_call('paas.snapshotprofile.list', options): profile['target'] = 'paas' ...
[ "def", "list", "(", "cls", ",", "options", "=", "None", ",", "target", "=", "None", ")", ":", "options", "=", "options", "or", "{", "}", "result", "=", "[", "]", "if", "not", "target", "or", "target", "==", "'paas'", ":", "for", "profile", "in", ...
List all snapshot profiles.
[ "List", "all", "snapshot", "profiles", "." ]
6ee5b8fc8ec44b0a6c232043ca610606ad8f693d
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/snapshotprofile.py#L46-L63
10,989
Gandi/gandi.cli
gandi/cli/modules/dns.py
Dns.records
def records(cls, fqdn, sort_by=None, text=False): """Display records information about a domain.""" meta = cls.get_fqdn_info(fqdn) url = meta['domain_records_href'] kwargs = {} if text: kwargs = {'headers': {'Accept': 'text/plain'}} return cls.json_get(cls.get...
python
def records(cls, fqdn, sort_by=None, text=False): """Display records information about a domain.""" meta = cls.get_fqdn_info(fqdn) url = meta['domain_records_href'] kwargs = {} if text: kwargs = {'headers': {'Accept': 'text/plain'}} return cls.json_get(cls.get...
[ "def", "records", "(", "cls", ",", "fqdn", ",", "sort_by", "=", "None", ",", "text", "=", "False", ")", ":", "meta", "=", "cls", ".", "get_fqdn_info", "(", "fqdn", ")", "url", "=", "meta", "[", "'domain_records_href'", "]", "kwargs", "=", "{", "}", ...
Display records information about a domain.
[ "Display", "records", "information", "about", "a", "domain", "." ]
6ee5b8fc8ec44b0a6c232043ca610606ad8f693d
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/dns.py#L51-L58
10,990
Gandi/gandi.cli
gandi/cli/modules/dns.py
Dns.add_record
def add_record(cls, fqdn, name, type, value, ttl): """Create record for a domain.""" data = { "rrset_name": name, "rrset_type": type, "rrset_values": value, } if ttl: data['rrset_ttl'] = int(ttl) meta = cls.get_fqdn_info(fqdn) ...
python
def add_record(cls, fqdn, name, type, value, ttl): """Create record for a domain.""" data = { "rrset_name": name, "rrset_type": type, "rrset_values": value, } if ttl: data['rrset_ttl'] = int(ttl) meta = cls.get_fqdn_info(fqdn) ...
[ "def", "add_record", "(", "cls", ",", "fqdn", ",", "name", ",", "type", ",", "value", ",", "ttl", ")", ":", "data", "=", "{", "\"rrset_name\"", ":", "name", ",", "\"rrset_type\"", ":", "type", ",", "\"rrset_values\"", ":", "value", ",", "}", "if", "t...
Create record for a domain.
[ "Create", "record", "for", "a", "domain", "." ]
6ee5b8fc8ec44b0a6c232043ca610606ad8f693d
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/dns.py#L61-L72
10,991
Gandi/gandi.cli
gandi/cli/modules/dns.py
Dns.update_record
def update_record(cls, fqdn, name, type, value, ttl, content): """Update all records for a domain.""" data = { "rrset_name": name, "rrset_type": type, "rrset_values": value, } if ttl: data['rrset_ttl'] = int(ttl) meta = cls.get_fqdn...
python
def update_record(cls, fqdn, name, type, value, ttl, content): """Update all records for a domain.""" data = { "rrset_name": name, "rrset_type": type, "rrset_values": value, } if ttl: data['rrset_ttl'] = int(ttl) meta = cls.get_fqdn...
[ "def", "update_record", "(", "cls", ",", "fqdn", ",", "name", ",", "type", ",", "value", ",", "ttl", ",", "content", ")", ":", "data", "=", "{", "\"rrset_name\"", ":", "name", ",", "\"rrset_type\"", ":", "type", ",", "\"rrset_values\"", ":", "value", "...
Update all records for a domain.
[ "Update", "all", "records", "for", "a", "domain", "." ]
6ee5b8fc8ec44b0a6c232043ca610606ad8f693d
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/dns.py#L75-L92
10,992
Gandi/gandi.cli
gandi/cli/modules/dns.py
Dns.del_record
def del_record(cls, fqdn, name, type): """Delete record for a domain.""" meta = cls.get_fqdn_info(fqdn) url = meta['domain_records_href'] delete_url = url if name: delete_url = '%s/%s' % (delete_url, name) if type: delete_url = '%s/%s' % (delete_ur...
python
def del_record(cls, fqdn, name, type): """Delete record for a domain.""" meta = cls.get_fqdn_info(fqdn) url = meta['domain_records_href'] delete_url = url if name: delete_url = '%s/%s' % (delete_url, name) if type: delete_url = '%s/%s' % (delete_ur...
[ "def", "del_record", "(", "cls", ",", "fqdn", ",", "name", ",", "type", ")", ":", "meta", "=", "cls", ".", "get_fqdn_info", "(", "fqdn", ")", "url", "=", "meta", "[", "'domain_records_href'", "]", "delete_url", "=", "url", "if", "name", ":", "delete_ur...
Delete record for a domain.
[ "Delete", "record", "for", "a", "domain", "." ]
6ee5b8fc8ec44b0a6c232043ca610606ad8f693d
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/dns.py#L95-L104
10,993
Gandi/gandi.cli
gandi/cli/modules/dns.py
Dns.keys
def keys(cls, fqdn, sort_by=None): """Display keys information about a domain.""" meta = cls.get_fqdn_info(fqdn) url = meta['domain_keys_href'] return cls.json_get(cls.get_sort_url(url, sort_by))
python
def keys(cls, fqdn, sort_by=None): """Display keys information about a domain.""" meta = cls.get_fqdn_info(fqdn) url = meta['domain_keys_href'] return cls.json_get(cls.get_sort_url(url, sort_by))
[ "def", "keys", "(", "cls", ",", "fqdn", ",", "sort_by", "=", "None", ")", ":", "meta", "=", "cls", ".", "get_fqdn_info", "(", "fqdn", ")", "url", "=", "meta", "[", "'domain_keys_href'", "]", "return", "cls", ".", "json_get", "(", "cls", ".", "get_sor...
Display keys information about a domain.
[ "Display", "keys", "information", "about", "a", "domain", "." ]
6ee5b8fc8ec44b0a6c232043ca610606ad8f693d
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/dns.py#L107-L111
10,994
Gandi/gandi.cli
gandi/cli/modules/dns.py
Dns.keys_info
def keys_info(cls, fqdn, key): """Retrieve key information.""" return cls.json_get('%s/domains/%s/keys/%s' % (cls.api_url, fqdn, key))
python
def keys_info(cls, fqdn, key): """Retrieve key information.""" return cls.json_get('%s/domains/%s/keys/%s' % (cls.api_url, fqdn, key))
[ "def", "keys_info", "(", "cls", ",", "fqdn", ",", "key", ")", ":", "return", "cls", ".", "json_get", "(", "'%s/domains/%s/keys/%s'", "%", "(", "cls", ".", "api_url", ",", "fqdn", ",", "key", ")", ")" ]
Retrieve key information.
[ "Retrieve", "key", "information", "." ]
6ee5b8fc8ec44b0a6c232043ca610606ad8f693d
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/dns.py#L114-L117
10,995
Gandi/gandi.cli
gandi/cli/modules/dns.py
Dns.keys_create
def keys_create(cls, fqdn, flag): """Create new key entry for a domain.""" data = { "flags": flag, } meta = cls.get_fqdn_info(fqdn) url = meta['domain_keys_href'] ret, headers = cls.json_post(url, data=json.dumps(data), ret...
python
def keys_create(cls, fqdn, flag): """Create new key entry for a domain.""" data = { "flags": flag, } meta = cls.get_fqdn_info(fqdn) url = meta['domain_keys_href'] ret, headers = cls.json_post(url, data=json.dumps(data), ret...
[ "def", "keys_create", "(", "cls", ",", "fqdn", ",", "flag", ")", ":", "data", "=", "{", "\"flags\"", ":", "flag", ",", "}", "meta", "=", "cls", ".", "get_fqdn_info", "(", "fqdn", ")", "url", "=", "meta", "[", "'domain_keys_href'", "]", "ret", ",", ...
Create new key entry for a domain.
[ "Create", "new", "key", "entry", "for", "a", "domain", "." ]
6ee5b8fc8ec44b0a6c232043ca610606ad8f693d
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/dns.py#L120-L129
10,996
Gandi/gandi.cli
gandi/cli/commands/vlan.py
list
def list(gandi, datacenter, id, subnet, gateway): """List vlans.""" output_keys = ['name', 'state', 'dc'] if id: output_keys.append('id') if subnet: output_keys.append('subnet') if gateway: output_keys.append('gateway') datacenters = gandi.datacenter.list() vlans = ...
python
def list(gandi, datacenter, id, subnet, gateway): """List vlans.""" output_keys = ['name', 'state', 'dc'] if id: output_keys.append('id') if subnet: output_keys.append('subnet') if gateway: output_keys.append('gateway') datacenters = gandi.datacenter.list() vlans = ...
[ "def", "list", "(", "gandi", ",", "datacenter", ",", "id", ",", "subnet", ",", "gateway", ")", ":", "output_keys", "=", "[", "'name'", ",", "'state'", ",", "'dc'", "]", "if", "id", ":", "output_keys", ".", "append", "(", "'id'", ")", "if", "subnet", ...
List vlans.
[ "List", "vlans", "." ]
6ee5b8fc8ec44b0a6c232043ca610606ad8f693d
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/vlan.py#L27-L45
10,997
Gandi/gandi.cli
gandi/cli/commands/vlan.py
info
def info(gandi, resource, ip): """Display information about a vlan.""" output_keys = ['name', 'state', 'dc', 'subnet', 'gateway'] datacenters = gandi.datacenter.list() vlan = gandi.vlan.info(resource) gateway = vlan['gateway'] if not ip: output_vlan(gandi, vlan, datacenters, output_ke...
python
def info(gandi, resource, ip): """Display information about a vlan.""" output_keys = ['name', 'state', 'dc', 'subnet', 'gateway'] datacenters = gandi.datacenter.list() vlan = gandi.vlan.info(resource) gateway = vlan['gateway'] if not ip: output_vlan(gandi, vlan, datacenters, output_ke...
[ "def", "info", "(", "gandi", ",", "resource", ",", "ip", ")", ":", "output_keys", "=", "[", "'name'", ",", "'state'", ",", "'dc'", ",", "'subnet'", ",", "'gateway'", "]", "datacenters", "=", "gandi", ".", "datacenter", ".", "list", "(", ")", "vlan", ...
Display information about a vlan.
[ "Display", "information", "about", "a", "vlan", "." ]
6ee5b8fc8ec44b0a6c232043ca610606ad8f693d
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/vlan.py#L52-L93
10,998
Gandi/gandi.cli
gandi/cli/commands/vlan.py
create
def create(gandi, name, datacenter, subnet, gateway, background): """ Create a new vlan """ try: gandi.datacenter.is_opened(datacenter, 'iaas') except DatacenterLimited as exc: gandi.echo('/!\ Datacenter %s will be closed on %s, ' 'please consider using another datacenter....
python
def create(gandi, name, datacenter, subnet, gateway, background): """ Create a new vlan """ try: gandi.datacenter.is_opened(datacenter, 'iaas') except DatacenterLimited as exc: gandi.echo('/!\ Datacenter %s will be closed on %s, ' 'please consider using another datacenter....
[ "def", "create", "(", "gandi", ",", "name", ",", "datacenter", ",", "subnet", ",", "gateway", ",", "background", ")", ":", "try", ":", "gandi", ".", "datacenter", ".", "is_opened", "(", "datacenter", ",", "'iaas'", ")", "except", "DatacenterLimited", "as",...
Create a new vlan
[ "Create", "a", "new", "vlan" ]
6ee5b8fc8ec44b0a6c232043ca610606ad8f693d
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/vlan.py#L144-L158
10,999
Gandi/gandi.cli
gandi/cli/commands/vlan.py
update
def update(gandi, resource, name, gateway, create, bandwidth): """ Update a vlan ``gateway`` can be a vm name or id, or an ip. """ params = {} if name: params['name'] = name vlan_id = gandi.vlan.usable_id(resource) try: if gateway: IP(gateway) param...
python
def update(gandi, resource, name, gateway, create, bandwidth): """ Update a vlan ``gateway`` can be a vm name or id, or an ip. """ params = {} if name: params['name'] = name vlan_id = gandi.vlan.usable_id(resource) try: if gateway: IP(gateway) param...
[ "def", "update", "(", "gandi", ",", "resource", ",", "name", ",", "gateway", ",", "create", ",", "bandwidth", ")", ":", "params", "=", "{", "}", "if", "name", ":", "params", "[", "'name'", "]", "=", "name", "vlan_id", "=", "gandi", ".", "vlan", "."...
Update a vlan ``gateway`` can be a vm name or id, or an ip.
[ "Update", "a", "vlan" ]
6ee5b8fc8ec44b0a6c232043ca610606ad8f693d
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/vlan.py#L172-L217