def run(self): karm = KArm() bc = Basecamp(self.url, self.user, self.password) counter = 0 # add projects as todo items to karm projects = bc.getProjects() todolists = bc.getTodoLists() if self.active_projects: active_ids = [todolist.project_id for todolist in todolists] projects = [project for project in projects if project.id in active_ids] for project in projects: karm.add(Todo( str(project.id), project.name, x_kde_ktimetracker_bctype='project' )) if self.cmdutil.debug: print "Added project: <%s>" % project.name # add todolists with their todo items to karm for todolist in todolists: project_id = str(todolist.project_id) task = karm.todos[project_id].add(Todo( str(todolist.id), todolist.name, related_to=project_id, x_kde_ktimetracker_bctype='todolist' )) if self.cmdutil.debug: print " Added todo list: <%s>" % todolist.name # add todo items eventually for todo in todolist.todo_items: hours = 0.0 if self.fetch_time: for time_entry in bc.getEntriesForTodoItem(todo.id): hours += float(time_entry.hours) task.add(Todo( str(todo.id), todo.content, related_to=str(todolist.id), x_kde_ktimetracker_bctype='todoitem', x_kde_ktimetracker_totaltasktime=str(int(hours * 60.0)) )) if self.cmdutil.debug: print " Added todo item: <%s>" % todo.content counter += 1 # dump result karm.dump(self.storage) if self.cmdutil.debug: print 'Added %d todo items...' % counter print 'Done...'
def show_logs(self,username='',password='',hours='',description=''): bc = Basecamp('https://seertechnologies.basecamphq.com','*****@*****.**','asdasd123') me = bc.getCurrentPerson().id total = 0.0 projects = bc.getProjects() print projects[0] #bc.createTimeEntryForProject(projects[0],hours=hours,person_id=me,description=description) for te in bc.getEntriesReport('2012-11-01', '2014-11-30', subject_id=me): print '%s: %0.2f' % (te.description, float(te.hours))
def show_logs(self, username='', password='', hours='', description=''): bc = Basecamp('', '', '') me = bc.getCurrentPerson().id total = 0.0 projects = bc.getProjects() print projects[0] #bc.createTimeEntryForProject(projects[0],hours=hours,person_id=me,description=description) for te in bc.getEntriesReport('', '', subject_id=me): print '%s: %0.2f' % (te.description, float(te.hours))
def show_logs(self,username='',password='',hours='',description=''): bc = Basecamp('','','') me = bc.getCurrentPerson().id total = 0.0 projects = bc.getProjects() print projects[0] #bc.createTimeEntryForProject(projects[0],hours=hours,person_id=me,description=description) for te in bc.getEntriesReport('', '', subject_id=me): print '%s: %0.2f' % (te.description, float(te.hours))
def show_logs(self, username='', password='', hours='', description=''): bc = Basecamp('https://seertechnologies.basecamphq.com', '*****@*****.**', 'asdasd123') me = bc.getCurrentPerson().id total = 0.0 projects = bc.getProjects() print projects[0] #bc.createTimeEntryForProject(projects[0],hours=hours,person_id=me,description=description) for te in bc.getEntriesReport('2012-11-01', '2014-11-30', subject_id=me): print '%s: %0.2f' % (te.description, float(te.hours))
def run(self): karm = KArm() karm.load(self.storage) bc = Basecamp(self.url, self.user, self.password) # flag that will show at the end whether something has been # updated eventually and if we really need to dump new storage updated = False # update projects projects = bc.getProjects() todolists = bc.getTodoLists() if self.active_projects: active_ids = [todolist.project_id for todolist in todolists] projects = [project for project in projects if project.id in active_ids] # firstly update projects for project in projects: task = karm.todos.get(str(project.id), None) if task is None: karm.add(Todo( str(project.id), project.name, x_kde_ktimetracker_bctype='project' )) updated = True if self.cmdutil.debug: print "Added project: <%s> [%d]" % (project.name, project.id) else: if task.summary != project.name: task.summary = project.name updated = True if self.cmdutil.debug: print "Updated project: <%s> [%d]" % (project.name, project.id) # then update todo lists with their todo items for todolist in todolists: project_id = str(todolist.project_id) task = karm.todos[project_id].todos.get(str(todolist.id), None) if task is None: task = karm.todos[project_id].add(Todo( str(todolist.id), todolist.name, related_to=project_id, x_kde_ktimetracker_bctype='todolist' )) updated = True if self.cmdutil.debug: print "Added todo list to project <%s> [%d]: <%s> [%d]" % ( karm.todos[project_id].summary, todolist.project_id, todolist.name, todolist.id ) else: if task.summary != todolist.name: task.summary = todolist.name updated = True if self.cmdutil.debug: print "Updated todo list: <%s> [%d] " \ "(project <%s> [%d])" % ( todolist.name, todolist.id, karm.todos[project_id].summary, todolist.project_id ) for todo in todolist.todo_items: new_todo = False subtask = task.todos.get(str(todo.id), None) if subtask is None: new_todo = True subtask = task.add(Todo( str(todo.id), todo.content, related_to=task.uid, x_kde_ktimetracker_bctype='todoitem' )) updated = True if self.cmdutil.debug: print "Added todo item <%s> to <%s> [%d] todolist " \ "(project <%s> [%d])" % ( todo.content, todolist.name, todolist.id, karm.todos[project_id].summary, todolist.project_id ) else: # TODO: todo.content string should be escaped # before comparison if subtask.summary != todo.content: subtask.summary = todo.content updated = True if self.cmdutil.debug: print "Updated todoitem #%d " \ "from <%s> todolist [%d] " \ "(<%s> project [%d])" % ( todolist.todo_items.index(todo), todolist.name, todolist.id, karm.todos[project_id].summary, todolist.project_id ) # update todo item's time if self.update_time: if subtask.x_kde_ktimetracker_totalsessiontime is None: subtask.x_kde_ktimetracker_totalsessiontime = '0' if subtask.x_kde_ktimetracker_totaltasktime is None: subtask.x_kde_ktimetracker_totaltasktime = '0' sessionMinutes = int(subtask.x_kde_ktimetracker_totalsessiontime) totalMinutes = int(subtask.x_kde_ktimetracker_totaltasktime) # fetch total todo item's time from basecamp hours = 0.0 for time_entry in bc.getEntriesForTodoItem(todo.id): hours += float(time_entry.hours) if int(hours * 60.0) != totalMinutes - sessionMinutes: subtask.x_kde_ktimetracker_totaltasktime = str( sessionMinutes + int(hours * 60.0) ) updated = True if new_todo and self.cmdutil.debug: print "Added total time to a newly created <%s> " \ "todo item to <%s> todo list [%d] " \ "(project <%s> [%d])" % ( todo.content, todolist.name, todolist.id, karm.todos[project_id].summary, todolist.project_id ) else: if self.cmdutil.debug: print "Updated todoitem's <%s> total time " \ "(todolist <%s> [%d], " \ "project <%s> [%d])" % ( todo.content, todolist.name, todolist.id, karm.todos[project_id].summary, todolist.project_id ) # dump result if something has changed if updated: karm.dump() if self.cmdutil.debug: print "Done..." elif self.cmdutil.debug: print "Nothing has changed..."