def verify(self): if (not self.publish and not self.unpublish and not self.deprecate and not self.undeprecate and not self.official and not self.noofficial): raise ActionAborted("No updates to perform.") print "\nProduct: {b}{s}{n}\n".format( b=Style.bright, s=self.product.spec, n=Style.normal, ) if self.publish: self._version_table(self.publish, title="Publish") if self.unpublish: self._version_table(self.unpublish, title="Un-publish") if self.deprecate: self._version_table(self.deprecate, title="Deprecate") if self.undeprecate: self._version_table(self.undeprecate, title="Un-deprecate") if self.official: self._version_table([self.official], title="Official") if self.noofficial: print "{o}: {b}{m}{n}\n".format( o="No official", b=Style.bright, m="This product will have no official versions.", n=Style.normal, ) if not Output.prompt_yes_no(Style.bright + "Update" + Style.reset): raise ActionAborted("User chose not to proceed.")
def verify(self): ptask_type_field = "Type" spec_field = "Spec" description_field = "Description" creator_field = "Creator" start_date_field = "Starts" due_date_field = "Due" source_field = "Source" output = Output() output.header_names = [ ptask_type_field, spec_field, description_field, creator_field, start_date_field, due_date_field, source_field, ] if self.source: source_disp = self.source.spec else: source_disp = "None" output.add_item( { ptask_type_field: self.ptask_type, spec_field: self.spec, description_field: self.description, creator_field: self.creator, start_date_field: str(self.start_date), due_date_field: str(self.due_date), source_field: source_disp, }, color_all=Style.bright, ) if self.force: output.title = "Creating:" else: output.title = "Confirm create:" output.dump() if not self.force: if self.ptask: if not Output.prompt_yes_no("This ptask already exists. " + \ Style.bright + "Continue anyway" + Style.reset): raise ActionAborted( "PTask already exists. User chose not to continue.") else: prompt_str = "Create " + Style.bright + self.spec + Style.reset if self.source: prompt_str += \ " + " + \ str(len(self.source.children_recursive)) + \ " child ptasks" if not Output.prompt_yes_no(prompt_str): raise ActionAborted("User chose not to proceed.")
def verify(self): code = "Code" name = "Name" description = "Description" server = "Data server" filesystem_root = "Filesystem root" output = Output() output.header_names = [ code, name, description, server, filesystem_root, ] output.add_item( { code: self.location.code, name: self.location.name, description: self.location.description, server: self.server, filesystem_root: self.location.filesystem_root, }, color_all=Style.bright, ) output.title = "Location summary:" output.dump() if not Output.prompt_yes_no( Style.bright + "Initialize location" + Style.reset ): raise ActionAborted("User chose not to proceed.")
def verify(self): next_version = self.ptask.next_version_number_padded ptask = "PTask" source_version = "Source version" description = "v{v} description".format(v=self.latest_version.number) output = Output() output.header_names = [ ptask, source_version, description, ] output.add_item({ ptask: Style.bright + str(self.ptask.spec) + Style.reset, source_version: \ Style.bright + \ str(self.source_version.number_padded) + \ Style.reset, description: Style.bright + str(self.description) + Style.reset, }) output.title = "Confirm version creation: {v}".format(v=next_version) output.dump() if not Output.prompt_yes_no(Style.bright + "Version up" + Style.reset): print "\nAborting!\n" raise ActionAborted("User aborted before version attempted.")
def verify(self): ptask_ver = "PTask version" product_ver = "Subscribing to" output = Output() output.title = "Source subscriptions from: " + self._version.spec output.header_names = [ ptask_ver, product_ver, ] for sub in self.subs_to_source: output.add_item( { ptask_ver: self.current_ptask_version.spec, product_ver: sub.product_version_spec, }, color_all=Style.bright, ) output.dump(output_format='table') if not Output.prompt_yes_no("Source"): raise ActionAborted("User chose not to proceed.")
def verify(self): prompt_str = "\nRefresh subscriptions for " + Style.bright + \ self.ptask.spec + Style.reset + " version " + Style.bright + \ self.ptask_version.number_padded + Style.reset + "\n" if not Output.prompt_yes_no(prompt_str): raise ActionAborted("User chose not to proceed.")
def verify(self): ptask_version = self.subscription.ptask_version product_version = self.subscription.product_version ptask = ptask_version.ptask product = product_version.product ptask_ver_header = "PTask version" product_ver_header = "Unsubscribing from" output = Output() output.title = "Removig subscription:" output.header_names = [ ptask_ver_header, product_ver_header, ] if product.official_version_number == product_version.number: official = Fg.green + " (official)" + Fg.reset else: official = "" output.add_item( { ptask_ver_header: ptask_version.spec, product_ver_header: product_version.spec + official, }, color_all=Style.bright, ) output.dump() if not Output.prompt_yes_no("Unsubscribe"): raise ActionAborted("User chose not to proceed.")
def verify(self): ver_range = Frange() ver_range.add([v.number for v in self.versions]) versions_disp = str(ver_range) ptask_field = "PTask" versions_field = "Version(s)" output = Output() output.header_names = [ ptask_field, versions_field, ] output.add_item( { ptask_field: self.ptask.spec, versions_field: versions_disp, }, color_all=Style.bright, ) if self.force: output.title = "Syncing: " else: output.title = "Confirm sync:" output.dump() if not self.force: if not Output.prompt_yes_no(Style.bright + "Sync" + Style.reset): raise ActionAborted("Sync aborted by user.")
def verify(self): ptask_ver = "PTask version" product_ver = "Subscribing to" output = Output() output.title = "Creating subscription:" output.header_names = [ ptask_ver, product_ver, ] if self.product.official_version_number == self.product_version.number: official = Fg.green + " (official)" + Fg.reset else: official = "" output.add_item( { ptask_ver: self.ptask_version.spec, product_ver: self.product_version.spec + official, }, color_all=Style.bright, ) output.dump() if self._existing_sub: print "Will unsubscribe from existing sub:\n " + \ Style.bright + self._existing_sub.product_version.spec + \ Style.normal + "\n" if not Output.prompt_yes_no("Subscribe"): raise ActionAborted("User chose not to proceed.")
def verify(self): if self._lock: self._sub_table(self._lock, title="Lock") if self._unlock: self._sub_table(self._unlock, title="Unlock") if not Output.prompt_yes_no(Style.bright + "Edit" + Style.reset): raise ActionAborted("User chose not to proceed.")
def verify(self): desc = "Description" ptask = "PTask" version = "Version" directory = "Directory" path = "Path" output = Output() output.header_names = [ desc, ptask, version, directory, ] if self.source_version: source_version_disp = self.source_version.number_padded else: source_version_disp = "Latest" if self.destination_version: destination_version_disp = self.destination_version.number_padded else: destination_version_disp = "Latest" output.add_item( { desc: 'Source', ptask: self.source.spec, version: source_version_disp, directory: str(self.source_directory), }, color_all=Style.bright, ) output.add_item( { desc: 'Destination', ptask: self.destination.spec, version: destination_version_disp, directory: str(self.destination_directory), }, color_all=Style.bright, ) output.title = "Confirm:" output.dump() if not Output.prompt_yes_no(Style.bright + "Sync" + Style.reset): raise ActionAborted("Sync canceled by user.")
def validate(self): # current ptask/version try: area = PTaskArea.current() self._current_ptask = PTask.get(area.spec) self._current_ptask_version = self._current_ptask.latest_version except PTaskError: raise ActionError("Unable to find ptask: " + str(self._ptask)) # source ptask if not isinstance(self._ptask, PTask): try: cur_spec = PTaskArea.current().spec full_spec = PTaskSpec.get(self._ptask, relative_to=cur_spec) self._ptask = PTask.get(full_spec) except PTaskError: raise ActionError("Unable to find ptask: " + str(self._ptask)) # source ptask version if isinstance(self._version, PTaskVersion): pass elif self._version: matches = PTaskVersion.list(ptask=self._ptask.spec, number=self._version) if len(matches) != 1: raise ActionError( "Unable to find ptask '{p}' at version '{v}'".format( p=self._ptask.spec, v=self._version)) else: self._version = matches[0] else: self._version = self._ptask.latest_version # source subs self._match_str = self._match_str.replace("%", ".*") all_subs = self._version.subscriptions self._subs_to_source = [] for sub in all_subs: if re.search(self._match_str, sub.product_version_spec): self._subs_to_source.append(sub) if not self._subs_to_source: raise ActionAborted("No subscriptions to source.")
def verify(self): name = "Name" category = "Category" description = "Description" file_type = "File type" resolution = "Resolution" ptask_ver = "PTask version" path = "Path" note = "Note" output = Output() output.header_names = [ name, category, description, file_type, resolution, ptask_ver, path, note, ] output.add_item( { name: self._name, category: self._category, description: self._description, file_type: self._file_type, resolution: self._resolution, ptask_ver: self._ptask_version.spec, path: self._path, note: self._note, }, color_all=Style.bright, ) output.title = "Confirm create:" output.dump() if not Output.prompt_yes_no(Style.bright + "Create" + Style.reset): raise ActionAborted("User chose not to proceed.")
def prompt(self): parent_spec = PTaskSpec.parent(self.spec) template_options = [] if parent_spec: par_ptask = PTask.get(parent_spec) par_ptask_type = par_ptask.ptask_type else: par_ptask_type = 'none' ptask_area = PTaskArea(parent_spec, validate=False) master_config = ptask_area.config( PROJECT_MASTER_CONFIG_PATH, composite_ancestors=True, ) if not master_config or not hasattr(master_config, 'hierarchy'): raise ActionError("Unable to find project master config.") if not self.ptask_type in master_config.hierarchy[par_ptask_type]: raise ActionError( "Cannot create '{t}' ptask inside '{p}' ptask".format( t=self.ptask_type, p=par_ptask_type, )) # ---- prompt for missing fields if not self.source and self.ptask_type in master_config.templates: for template_spec in master_config.templates[self.ptask_type]: trimmed_spec = re.sub("^templates?=", "", template_spec, flags=re.IGNORECASE) template_options.append( (re.sub("[=_-]+", " ", trimmed_spec).title(), template_spec)) self._source = Output.prompt_menu( "Select a template to source", prompt_str="Selection", options=template_options, help_str="Please choose from the templates listed.", none_option=True, custom_prompt="Custom Source", custom_blank=False) # see if the ptask already exists if not self.ptask: try: self._ptask = PTask.get(self.spec) except PTaskError: pass else: if not self.force: raise ActionAborted("PTask already exists.") else: if not self._description: self._description = self.ptask.description if not self._start_date: self._start_date = self.ptask.start_date if not self._due_date: self._due_date = self.ptask.due_date if (not self.description or not self.start_date or not self.due_date): if self.force: raise ActionError( "Cannot force creation without required fields.") else: print "\nPlease enter information about this new {b}{t}{r}:".\ format( b=Style.bright, t=self.ptask_type, r=Style.reset, ) ptask_display = " [{pt}] {b}{s}{r}".format( pt=self.ptask_type, b=Style.bright, s=self.spec, r=Style.reset, ) if not self.description: self._description = Output.prompt( '{pd} description'.format(pd=ptask_display), blank=False, ) if not self.start_date: self._start_date = Output.prompt_date( '{pd} start date'.format(pd=ptask_display), blank=False, ) if not self.due_date: self._due_date = Output.prompt_date( '{pd} due date'.format(pd=ptask_display), blank=False, )