def run_add(self): t = Template(self.args.template, user=self.args.username) # add template bits that are specified if self.args.title is not None: t.title = self.args.title if self.args.description is not None: t.description = self.args.description if self.args.includes is not None: t.includes = self.args.includes if self.args.public is not None: t.public = self.args.public try: res = self.cs.template_create(t) except ServiceException as e: logging.exception(e) return 1 logging.info('Template added.') return 0
def run_update(self): t = Template(self.args.template, user=self.args.username) try: t = self.cs.template_get(t, resolve_includes=False) except ServiceException as e: logging.exception(e) return 1 # add template bits that are specified for update if self.args.title is not None: t.title = self.args.title if self.args.description is not None: t.description = self.args.description if self.args.includes is not None: t.includes = self.args.includes if self.args.public is not None: t.public = self.args.public try: res = self.cs.template_update(t) except ServiceException as e: logging.exception(e) return 1 logging.info('Template updated.') return 0
def run_add(self): t = Template(self.args.template, user=self.args.username) if self.args.username: if not self.cs.authenticate(self.args.username, getpass.getpass('Password ({0}): '.format(self.args.username))): print('error: unable to authenticate with canvas service.') return 1 # add template bits that are specified if self.args.title is not None: t.title = self.args.title if self.args.description is not None: t.description = self.args.description if self.args.includes is not None: t.includes = self.args.includes if self.args.public is not None: t.public = self.args.public try: res = self.cs.template_create(t) except ServiceException as e: print(e) return 1 print('info: template added.') return 0