code stringlengths 1 18.2k |
|---|
in dests] if self.porttype == 'DataInPort': if 'DataOutPort' not in ptypes: raise exceptions.WrongPortTypeError if self.porttype == 'DataOutPort': if 'DataInPort' not in ptypes: raise exceptions.WrongPortTypeError if 'dataport.dataflow_type' not in new_props: new_props['dataport.dataflow_type'] = 'push' if 'dataport.in... |
def connect(self, dests=None, name=None, id='', props={}): '''Connect this port to other CorbaPorts. After the connection has been made, a delayed reparse of the connections for this and the destination port will be triggered. @param dests A list of the destination Port objects. Must be provided. @param name The name o... |
in dests: if not d.porttype == 'CorbaPort': raise exceptions.WrongPortTypeError # Check the interfaces and their respective polarities match if self.interfaces: for d in dests: if not d.interfaces: raise exceptions.MismatchedInterfacesError for intf in self.interfaces: for d in dests: match = d.get_interface_by_instanc... |
def get_interface_by_instance_name(self, name): '''Get an interface of this port by instance name.''' with self._mutex: for intf in self.interfaces: if intf.instance_name == name: return intf return None |
def interfaces(self): '''The list of interfaces this port provides or uses. This list will be created at the first reference to this property. This means that the first reference may be delayed by CORBA calls, but others will return quickly (unless a delayed reparse has been triggered). ''' with self._mutex: if not sel... |
def polarity_as_string(self, add_colour=True): '''Get the polarity of this interface as a string. @param add_colour If True, ANSI colour codes will be added to the string. @return A string describing the polarity of this interface. ''' with self._mutex: if self.polarity == self.PROVIDED: result = 'Provided', ['reset'] ... |
def disconnect(self): '''Disconnect this connection.''' with self._mutex: if not self.ports: raise exceptions.NotConnectedError # Some of the connection participants may not be in the tree, # causing the port search in self.ports to return ('Unknown', None) # for those participants. Search the list to find the first # ... |
def has_port(self, port): '''Return True if this connection involves the given Port object. @param port The Port object to search for in this connection's ports. ''' with self._mutex: for p in self.ports: if not p[1]: # Port owner not in tree, so unknown continue if port.object._is_equivalent(p[1].object): return True ... |
def ports(self): '''The list of ports involved in this connection. The result is a list of tuples, (port name, port object). Each port name is a full path to the port (e.g. /localhost/Comp0.rtc:in) if this Connection object is owned by a Port, which is in turn owned by a Component in the tree. Otherwise, only the port'... |
list will be created at the first reference to this property. This means that the first reference may be delayed by CORBA calls, but others will return quickly (unless a delayed reparse has been triggered). ''' def has_port(node, args): if node.get_port_by_ref(args): return node return None with self._mutex: if not sel... |
def analysis(self): """Get musical analysis of the song using the librosa library """ if self._analysis is not None: return self._analysis if self.cache_dir is not None: path = os.path.join(self.cache_dir, self.checksum) try: if self.refresh_cache: raise IOError with open(path + '.pickle', 'rb') as pickle_file: self._a... |
def breeding_pups(request, breeding_id): """This view is used to generate a form by which to add pups which belong to a particular breeding set. This view is intended to be used to add initial information about pups, including eartag, genotype, gender and birth or weaning information. It takes a request in the form /br... |
formset = PupsFormSet(instance=breeding) return render("breeding_pups.html", {"formset":formset, 'breeding':breeding}) |
def breeding_change(request, breeding_id): """This view is used to generate a form by which to change pups which belong to a particular breeding set. This view typically is used to modify existing pups. This might include marking animals as sacrificed, entering genotype or marking information or entering movement of mi... |
is restricted to those with the permission animal.change_animal. """ breeding = Breeding.objects.select_related().get(id=breeding_id) strain = breeding.Strain PupsFormSet = inlineformset_factory(Breeding, Animal, extra=0, exclude=('Alive','Father', 'Mother', 'Breeding', 'Notes')) if request.method =="POST": formset = P... |
def breeding_wean(request, breeding_id): """This view is used to generate a form by which to wean pups which belong to a particular breeding set. This view typically is used to wean existing pups. This includes the MouseID, Cage, Markings, Gender and Wean Date fields. For other fields use the breeding-change page. It t... |
= breeding.Strain PupsFormSet = inlineformset_factory(Breeding, Animal, extra=0, exclude=('Alive','Father', 'Mother', 'Breeding', 'Notes','Rack','Rack_Position','Strain','Background','Genotype','Death','Cause_of_Death','Backcross','Generation')) if request.method =="POST": formset = PupsFormSet(request.POST, instance=b... |
def multiple_pups(request): """This view is used to enter multiple animals at the same time. It will generate a form containing animal information and a number of mice. It is intended to create several identical animals with the same attributes. """ if request.method == "POST": form = MultipleAnimalForm(request.POST) i... |
def multiple_breeding_pups(request, breeding_id): """This view is used to enter multiple animals at the same time from a breeding cage. It will generate a form containing animal information and a number of mice. It is intended to create several identical animals with the same attributes. This view requres an input of a... |
{"form":form, "breeding":breeding}) |
def date_archive_year(request): """This view will generate a table of the number of mice born on an annual basis. This view is associated with the url name archive-home, and returns an dictionary of a date and a animal count.""" oldest_animal = Animal.objects.filter(Born__isnull=False).order_by('Born')[0] archive_dict ... |
def todo(request): """This view generates a summary of the todo lists. The login restricted view passes lists for ear tagging, genotyping and weaning and passes them to the template todo.html.""" eartag_list = Animal.objects.filter(Born__lt=(datetime.date.today() - datetime.timedelta(days=settings.WEAN_AGE))).filter(Mo... |
def dispatch(self, *args, **kwargs): """This decorator sets this view to have restricted permissions.""" return super(AnimalList, self).dispatch(*args, **kwargs) |
def get_context_data(self, **kwargs): """This add in the context of list_type and returns this as Alive.""" context = super(AnimalListAlive, self).get_context_data(**kwargs) context['list_type'] = 'Alive' return context |
def dispatch(self, *args, **kwargs): """This decorator sets this view to have restricted permissions.""" return super(AnimalCreate, self).dispatch(*args, **kwargs) |
def dispatch(self, *args, **kwargs): """This decorator sets this view to have restricted permissions.""" return super(AnimalUpdate, self).dispatch(*args, **kwargs) |
def dispatch(self, *args, **kwargs): """This decorator sets this view to have restricted permissions.""" return super(AnimalDelete, self).dispatch(*args, **kwargs) |
def get_context_data(self, **kwargs): """This add in the context of strain_list_alive (which filters for all alive animals) and cages which filters for the number of current cages.""" context = super(StrainList, self).get_context_data(**kwargs) context['strain_list_alive'] = Strain.objects.filter(animal__Alive=True).an... |
def get_context_data(self, **kwargs): """This adds into the context of strain_list_all (which filters for all alive :class:`~mousedb.animal.models.Animal` objects and active cages) and cages which filters for the number of current cages.""" strain = super(StrainDetail, self).get_object() context = super(StrainDetail, s... |
def dispatch(self, *args, **kwargs): """This decorator sets this view to have restricted permissions.""" return super(StrainCreate, self).dispatch(*args, **kwargs) |
def dispatch(self, *args, **kwargs): """This decorator sets this view to have restricted permissions.""" return super(StrainUpdate, self).dispatch(*args, **kwargs) |
def dispatch(self, *args, **kwargs): """This decorator sets this view to have restricted permissions.""" return super(StrainDelete, self).dispatch(*args, **kwargs) |
def get_context_data(self, **kwargs): """This adds into the context of breeding_type and sets it to Active.""" context = super(BreedingList, self).get_context_data(**kwargs) context['breeding_type'] = "Active" return context |
def get_context_data(self, **kwargs): """This add in the context of breeding_type and sets it to Search it also returns the query and the queryset.""" query = self.request.GET.get('q', '') context = super(BreedingSearch, self).get_context_data(**kwargs) context['breeding_type'] = "Search" context['query'] = query if qu... |
def dispatch(self, *args, **kwargs): """This decorator sets this view to have restricted permissions.""" return super(BreedingCreate, self).dispatch(*args, **kwargs) |
def dispatch(self, *args, **kwargs): """This decorator sets this view to have restricted permissions.""" return super(BreedingUpdate, self).dispatch(*args, **kwargs) |
def dispatch(self, *args, **kwargs): """This decorator sets this view to have restricted permissions.""" return super(BreedingDelete, self).dispatch(*args, **kwargs) |
def dispatch(self, *args, **kwargs): """This decorator sets this view to have restricted permissions.""" return super(AnimalYearArchive, self).dispatch(*args, **kwargs) |
def dispatch(self, *args, **kwargs): """This decorator sets this view to have restricted permissions.""" return super(AnimalMonthArchive, self).dispatch(*args, **kwargs) |
def queryset(self): """This function sets the queryset according to the keyword arguments. For the crosstype, the input value is the the display value of CROSS_TYPE. This is done because the spaces in HET vs HET are not recognized. Therefore the queryset must be matched exactly (ie by case so Intercross not intercross)... |
def get_context_data(self, **kwargs): """This add in the context of list_type and returns this as whatever the crosstype was.""" context = super(CrossTypeAnimalList, self).get_context_data(**kwargs) context['list_type'] = self.kwargs['breeding_type'] return context |
def get_context_data(self, **kwargs): '''Adds to the context all issues, conditions and treatments.''' context = super(VeterinaryHome, self).get_context_data(**kwargs) context['medical_issues'] = MedicalIssue.objects.all() context['medical_conditions'] = MedicalCondition.objects.all() context['medical_treatments'] = Me... |
def read_frames(self, n, channels=None): """Read ``n`` frames from the track, starting with the current frame :param integer n: Number of frames to read :param integer channels: Number of channels to return (default is number of channels in track) :returns: Next ``n`` frames from the track, starting with ``current_fram... |
out = np.vstack((frames.copy(), frames.copy())).T elif self.channels == 2 and channels == 1: frames = self.sound.read_frames(n) out = np.mean(frames, axis=1) elif self.channels == 2 and channels == 2: out[:n, :] = self.sound.read_frames(n) self.current_frame += n return out |
def current_frame(self, n): """Sets current frame to ``n`` :param integer n: Frame to set to ``current_frame`` """ self.sound.seek(n) self._current_frame = n |
def range_as_mono(self, start_sample, end_sample): """Get a range of frames as 1 combined channel :param integer start_sample: First frame in range :param integer end_sample: Last frame in range (exclusive) :returns: Track frames in range as 1 combined channel :rtype: 1d numpy array of length ``end_sample - start_sampl... |
def loudest_time(self, start=0, duration=0): """Find the loudest time in the window given by start and duration Returns frame number in context of entire track, not just the window. :param integer start: Start frame :param integer duration: Number of frames to consider from start :returns: Frame number of loudest frame... |
def zero_crossing_before(self, n): """Find nearest zero crossing in waveform before frame ``n``""" n_in_samples = int(n * self.samplerate) search_start = n_in_samples - self.samplerate if search_start < 0: search_start = 0 frame = zero_crossing_last( self.range_as_mono(search_start, n_in_samples)) + search_start return... |
def zero_crossing_after(self, n): """Find nearest zero crossing in waveform after frame ``n``""" n_in_samples = int(n * self.samplerate) search_end = n_in_samples + self.samplerate if search_end > self.duration: search_end = self.duration frame = zero_crossing_first( self.range_as_mono(n_in_samples, search_end)) + n_in... |
def label(self, t): """Get the label of the song at a given time in seconds """ if self.labels is None: return None prev_label = None for l in self.labels: if l.time > t: break prev_label = l if prev_label is None: return None return prev_label.name |
def set_param(self, param, value): '''Set a parameter in this configuration set.''' self.data[param] = value self._object.configuration_data = utils.dict_to_nvlist(self.data) |
def _reload(self, object, description, data): '''Reload the configuration set data.''' self._object = object self._description = description self._data = data |
def setting(self): """ Load setting (Amps, Watts, or Ohms depending on program mode) """ prog_type = self.__program.program_type return self._setting / self.SETTING_DIVIDES[prog_type] |
def partial_steps_data(self, start=0): """ Iterates 5 steps from start position and provides tuple for packing into buffer. returns (0, 0) if stpe doesn't exist. :param start: Position to start from (typically 0 or 5) :yield: (setting, duration) """ cnt = 0 if len(self._prog_steps) >= start: # yields actual steps for e... |
def add_step(self, setting, duration): """ Adds steps to a program. :param setting: Current, Wattage or Resistance, depending on program mode. :param duration: Length of step in seconds. :return: None """ if len(self._prog_steps) < 10: self._prog_steps.append(ProgramStep(self, setting, duration)) else: raise IndexError... |
def load_buffer_one_to_five(self, out_buffer): """ Loads first program buffer (0x93) with everything but first three bytes and checksum """ struct.pack_into(b"< 2B", out_buffer, 3, self._program_type, len(self._prog_steps)) offset = 5 for ind, step in enumerate(self.partial_steps_data(0)): struct.pack_into(b"< 2H", out... |
def load_buffer_six_to_ten(self, out_buffer): """ Loads second program buffer (0x94) with everything but first three bytes and checksum """ offset = 3 for ind, step in enumerate(self.partial_steps_data(5)): struct.pack_into(b"< 2H", out_buffer, offset + ind*4, step[0], step[1]) struct.pack_into(b"< B x", out_buffer, 23... |
def set_load_resistance(self, resistance): """ Changes load to resistance mode and sets resistance value. Rounds to nearest 0.01 Ohms :param resistance: Load Resistance in Ohms (0-500 ohms) :return: None """ new_val = int(round(resistance * 100)) if not 0 <= new_val <= 50000: raise ValueError("Load Resistance should be... |
def set_load_power(self, power_watts): """ Changes load to power mode and sets power value. Rounds to nearest 0.1W. :param power_watts: Power in Watts (0-200) :return: """ new_val = int(round(power_watts * 10)) if not 0 <= new_val <= 2000: raise ValueError("Load Power should be between 0-200 W") self._load_mode = self.... |
def set_load_current(self, current_amps): """ Changes load to current mode and sets current value. Rounds to nearest mA. :param current_amps: Current in Amps (0-30A) :return: None """ new_val = int(round(current_amps * 1000)) if not 0 <= new_val <= 30000: raise ValueError("Load Current should be between 0-30A") self._l... |
def __set_buffer_start(self, command): """ This sets the first three bytes and clears the other 23 bytes. :param command: Command Code to set :return: None """ self.STRUCT_FRONT.pack_into(self.__out_buffer, self.OFFSET_FRONT, 0xAA, self.address, command) |
def __set_checksum(self): """ Sets the checksum on the last byte of buffer, based on values in the buffer :return: None """ checksum = self.__get_checksum(self.__out_buffer.raw) self.STRUCT_CHECKSUM.pack_into(self.__out_buffer, self.OFFSET_CHECKSUM, checksum) |
def __clear_in_buffer(self): """ Zeros out the in buffer :return: None """ self.__in_buffer.value = bytes(b'\0' * len(self.__in_buffer)) |
def __send_buffer(self): """ Sends the contents of self.__out_buffer to serial device :return: Number of bytes written """ bytes_written = self.serial.write(self.__out_buffer.raw) if self.DEBUG_MODE: print("Wrote: '{}'".format(binascii.hexlify(self.__out_buffer.raw))) if bytes_written != len(self.__out_buffer): raise I... |
def __send_receive_buffer(self): """ Performs a send of self.__out_buffer and then an immediate read into self.__in_buffer :return: None """ self.__clear_in_buffer() self.__send_buffer() read_string = self.serial.read(len(self.__in_buffer)) if self.DEBUG_MODE: print("Read: '{}'".format(binascii.hexlify(read_string))) i... |
def __set_parameters(self): """ Sets Load Parameters from class values, including: Max Current, Max Power, Address, Load Mode, Load Value :return: None """ self.__set_buffer_start(self.CMD_SET_PARAMETERS) # Can I send 0xFF as address to not change it each time? # Worry about writing to EEPROM or Flash with each address... |
def update_status(self, retry_count=2): """ Updates current values from load. Must be called to get latest values for the following properties of class: current voltage power max current max power resistance local_control load_on wrong_polarity excessive_temp excessive_voltage excessive_power :param retry_count: Number... |
self.excessive_temp = (output_state & 0b00001000) > 0 self.excessive_voltage = (output_state & 0b00010000) > 0 self.excessive_power = (output_state & 0b00100000) > 0 return None cur_count -= 1 raise IOError("Retry count exceeded with serial IO.") |
def set_program_sequence(self, array_program): """ Sets program up in load. :param array_program: Populated Array3710Program object :return: None """ self.__set_buffer_start(self.CMD_DEFINE_PROG_1_5) array_program.load_buffer_one_to_five(self.__out_buffer) self.__set_checksum() self.__send_buffer() self.__set_buffer_st... |
def start_program(self, turn_on_load=True): """ Starts running programmed test sequence :return: None """ self.__set_buffer_start(self.CMD_START_PROG) self.__set_checksum() self.__send_buffer() # Turn on Load if not on if turn_on_load and not self.load_on: self.load_on = True |
def stop_program(self, turn_off_load=True): """ Stops running programmed test sequence :return: None """ self.__set_buffer_start(self.CMD_STOP_PROG) self.__set_checksum() self.__send_buffer() if turn_off_load and self.load_on: self.load_on = False |
def run(self): """ Calls the `perform()` method defined by subclasses and stores the result in a `results` deque. After the result is determined the `results` deque is analyzed to see if the `passing` flag should be updated. If the check was considered passing and the previous `self.fall` number of checks failed, the c... |
and all(self.last_n_results(self.rise)): logger.info( "%s check passed %d time(s), is now passing.", self.name, self.rise ) self.passing = True |
def last_n_results(self, n): """ Helper method for returning a set number of the previous check results. """ return list( itertools.islice( self.results, len(self.results) - n, len(self.results) ) ) |
def apply_config(self, config): """ Sets attributes based on the given config. Also adjusts the `results` deque to either expand (padding itself with False results) or contract (by removing the oldest results) until it matches the required length. """ self.rise = int(config["rise"]) self.fall = int(config["fall"]) self... |
def validate_config(cls, config): """ Validates that required config entries are present. Each check requires a `host`, `port`, `rise` and `fall` to be configured. The rise and fall variables are integers denoting how many times a check must pass before being considered passing and how many times a check must fail befo... |
def vectorize(self, docs): """ Vectorizes a list of documents using their DCS representations. """ doc_core_sems, all_concepts = self._extract_core_semantics(docs) shape = (len(docs), len(all_concepts)) vecs = np.zeros(shape) for i, core_sems in enumerate(doc_core_sems): for con, weight in core_sems: j = all_concepts.i... |
def _process_doc(self, doc): """ Applies DCS to a document to extract its core concepts and their weights. """ # Prep doc = doc.lower() tagged_tokens = [(t, penn_to_wordnet(t.tag_)) for t in spacy(doc, tag=True, parse=False, entity=False)] tokens = [t for t, tag in tagged_tokens] term_concept_map = self._disambiguate_d... |
def _disambiguate_doc(self, tagged_tokens): """ Takes a list of tagged tokens, representing a document, in the form: [(token, tag), ...] And returns a mapping of terms to their disambiguated concepts (synsets). """ # Group tokens by PoS pos_groups = {pos: [] for pos in [wn.NOUN, wn.VERB, wn.ADJ, wn.ADV]} for tok, tag i... |
def _disambiguate_pos(self, terms, pos): """ Disambiguates a list of tokens of a given PoS. """ # Map the terms to candidate concepts # Consider only the top 3 most common senses candidate_map = {term: wn.synsets(term, pos=pos)[:3] for term in terms} # Filter to unique concepts concepts = set(c for cons in candidate_ma... |
# and thus have no candidate concepts, so skip if not cons: continue scores = [] for con in cons: i = concepts.index(con) scores_ = [] for term_, cons_ in candidate_map.items(): # Some words may not be in WordNet # and thus have no candidate concepts, so skip if term == term_ or not cons_: continue cons_idx = [concepts... |
def _similarity_matrix(self, concepts): """ Computes a semantic similarity matrix for a set of concepts. """ n_cons = len(concepts) sim_mat = np.zeros((n_cons, n_cons)) for i, c1 in enumerate(concepts): for j, c2 in enumerate(concepts): # Just build the lower triangle if i >= j: sim_mat[i,j] = self._semsim(c1, c2) if i... |
def _semsim(self, c1, c2): """ Computes the semantic similarity between two concepts. The semantic similarity is a combination of two sem sims: 1. An "explicit" sem sim metric, that is, one which is directly encoded in the WordNet graph. Here it is just Wu-Palmer similarity. 2. An "implicit" sem sim metric. See `_imp_s... |
need_root = c1._needs_root() subsumers = c1.lowest_common_hypernyms(c2, simulate_root=need_root) if not subsumers: # For relationships not in WordNet, fallback on just implicit semsim. return self._imp_semsim(c1, c2) subsumer = subsumers[0] depth = subsumer.max_depth() + 1 len1 = c1.shortest_path_distance(subsumer, sim... |
def _imp_semsim(self, c1, c2): """ The paper's implicit semantic similarity metric involves iteratively computing string overlaps; this is a modification where we instead use inverse Sift4 distance (a fast approximation of Levenshtein distance). Frankly ~ I don't know if this is an appropriate substitute, so I'll have ... |
def _core_semantics(self, lex_chains, concept_weights): """ Returns the n representative lexical chains for a document. """ chain_scores = [self._score_chain(lex_chain, adj_submat, concept_weights) for lex_chain, adj_submat in lex_chains] scored_chains = zip(lex_chains, chain_scores) scored_chains = sorted(scored_chain... |
def _extract_core_semantics(self, docs): """ Extracts core semantics for a list of documents, returning them along with a list of all the concepts represented. """ all_concepts = [] doc_core_sems = [] for doc in docs: core_sems = self._process_doc(doc) doc_core_sems.append(core_sems) all_concepts += [con for con, weigh... |
def _lexical_chains(self, doc, term_concept_map): """ Builds lexical chains, as an adjacency matrix, using a disambiguated term-concept map. """ concepts = list({c for c in term_concept_map.values()}) # Build an adjacency matrix for the graph # Using the encoding: # 1 = identity/synonymy, 2 = hypernymy/hyponymy, 3 = me... |
in c_.member_meronyms() + c_.part_meronyms() + c_.substance_meronyms(): edge = 3 adj_mat[i,j] = edge # Group connected concepts by labels concept_labels = connected_components(adj_mat, directed=False)[1] lexical_chains = [([], []) for i in range(max(concept_labels) + 1)] for i, concept in enumerate(concepts): label = c... |
def _score_chain(self, lexical_chain, adj_submat, concept_weights): """ Computes the score for a lexical chain. """ scores = [] # Compute scores for concepts in the chain for i, c in enumerate(lexical_chain): score = concept_weights[c] * self.relation_weights[0] rel_scores = [] for j, c_ in enumerate(lexical_chain): if... |
def _weight_concepts(self, tokens, term_concept_map): """ Calculates weights for concepts in a document. This is just the frequency of terms which map to a concept. """ weights = {c: 0 for c in term_concept_map.values()} for t in tokens: # Skip terms that aren't one of the PoS we used if t not in term_concept_map: cont... |
def _description(self, concept): """ Returns a "description" of a concept, as defined in the paper. The paper describes the description as a string, so this is a slight modification where we instead represent the definition as a list of tokens. """ if concept not in self.descriptions: lemmas = concept.lemma_names() glo... |
def _related(self, concept): """ Returns related concepts for a concept. """ return concept.hypernyms() + \ concept.hyponyms() + \ concept.member_meronyms() + \ concept.substance_meronyms() + \ concept.part_meronyms() + \ concept.member_holonyms() + \ concept.substance_holonyms() + \ concept.part_holonyms() + \ concept... |
def init_tasks(): """ Performs basic setup before any of the tasks are run. All tasks needs to run this before continuing. It only fires once. """ # Make sure exist are set if "exists" not in env: env.exists = exists if "run" not in env: env.run = run if "cd" not in env: env.cd = cd if "max_releases" not in env: env.ma... |
def setup(): """ Creates shared and upload directory then fires setup to recipes. """ init_tasks() run_hook("before_setup") # Create shared folder env.run("mkdir -p %s" % (paths.get_shared_path())) env.run("chmod 755 %s" % (paths.get_shared_path())) # Create backup folder env.run("mkdir -p %s" % (paths.get_backup_path(... |
def deploy(): """ Performs a deploy by invoking copy, then generating next release name and invoking necessary hooks. """ init_tasks() if not has_hook("copy"): return report("No copy method has been defined") if not env.exists(paths.get_shared_path()): return report("You need to run setup before running deploy") run_ho... |
def rollback(): """ Rolls back to previous release """ init_tasks() run_hook("before_rollback") # Remove current version current_release = paths.get_current_release_path() if current_release: env.run("rm -rf %s" % current_release) # Restore previous version old_release = paths.get_current_release_name() if old_release:... |
def cleanup_releases(limit=5): """ Removes older releases. """ init_tasks() max_versions = limit + 1 env.run("ls -dt %s/*/ | tail -n +%s | xargs rm -rf" % ( paths.get_releases_path(), max_versions) ) |
def from_db(cls, db, force=False): """Make instance from database. For performance, this caches the episode types for the database. The `force` parameter can be used to bypass this. """ if force or db not in cls._cache: cls._cache[db] = cls._new_from_db(db) return cls._cache[db] |
def pipe_shell_cmds(shell_CMDs): ''' shell_CMDs = {} shell_CMDs[1] = 'netstat -n' shell_CMDs[2] = "awk {'print $6'}" ''' len = shell_CMDs.__len__() p = {} p[1] = subprocess.Popen(shlex.split(shell_CMDs[1]), stdout=subprocess.PIPE,stderr=subprocess.PIPE) for i in range(2,len): p[i] = subprocess.Popen(shlex.split(shell_C... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.