def process(self, args): """ Process this command :param args: :return: 0 if command was successful, value!=0 means command was not successful :rtype: int """ if log.isEnabledFor(logging.DEBUG): log.debug(Lfm("{0}Cat command is in charge {0}\\", os.linesep)) log.debug(Lfm(" |- arguments : '" + "' '".join(args) + "'")) assert self.context is not None # reset arguments on each process self.raw_table_path = "" self.show_borders = True self.show_header = True self.show_comments = False self.show_date = False self.request = ParseRequestResult() self.ass_id = 0 self.user_request_print_horizontal = False self.user_request_print_vertical = False if not len(args): print "Please provide ID for assignment. Use 'help cat' to get more information" return 1 if not self.process_arguments(args): return 1 if self.use_ass_id: assignment = self.get_assignment_by_id(self.ass_id) else: assignment = self.get_assignment_by_request(self.request) if assignment: # now we have to know, how to print an assignment data = assignment.constant_set.data_table if len(data) and len(data[0]): if self.user_request_print_horizontal: self.print_assignment_horizontal(assignment, self.show_header, self.show_borders, self.show_comments) elif self.user_request_print_vertical: self.print_assignment_vertical(assignment, self.show_header, self.show_borders, self.show_comments) else: if len(data) == 1 and len(data[0]) > 3: self.print_assignment_vertical(assignment, self.show_header, self.show_borders, self.show_comments) else: self.print_assignment_horizontal(assignment, self.show_header, self.show_borders, self.show_comments) else: log.warning("Assignment contains no data") else: print "Cannot fill data for assignment with this ID" return 1 return 0
def __init__(self): ConsoleUtilBase.__init__(self) self.raw_entry = "/" # object path with possible pattern, like /mole/* self.path = "/" # parent path self.raw_table_path = "" self.use_ass_id = False self.ass_id = 0 self.print_horizontal = True self.user_request_print_horizontal = False self.user_request_print_vertical = False self.request = ParseRequestResult()