コード例 #1
0
ファイル: track.py プロジェクト: jaderigby/timeTracking
def execute(REPRESS_STATUS):
    record = helpers.load_record()

    current = record['current']

    if current == '':
        msg.no_current_project()
    else:
        recordedTime = helpers.time_stamp()
        obj = {}
        # print json.dumps(record, sort_keys=True, indent=4)
        for item in record['projects'][current]['time']:
            if item['end'] == '':
                obj = item

        if len(obj) <= 0 and not REPRESS_STATUS:
            newItem = helpers.new_time_obj(recordedTime)
            record['projects'][current]['time'].append(newItem)

            content = helpers.glue_updated_record(record)
            helpers.write_file(helpers.recordPath, content)

            msg.tracking_message(newItem, current)
        elif REPRESS_STATUS:
            msg.new_project_tracking(current, recordedTime)
        else:
            msg.already_tracking(current)
コード例 #2
0
ファイル: untrack.py プロジェクト: jaderigby/timeTracking
def execute():
    record = helpers.load_record()

    current = record['current']

    if current == "":
        msg.no_current_project()
    else:
        obj = {}
        spentList = []
        for item in record['projects'][current]['time']:
            spentList.append(item['spent'])
            if item['end'] == '':
                obj = item

        if len(obj) > 0:
            recordedTime = helpers.time_stamp()
            recordedDate = helpers.date_stamp()
            obj['end'] = recordedTime
            obj['spent'] = helpers.time_spent(obj['start'], obj['end'])
            obj['spent_date'] = recordedDate

            content = helpers.glue_updated_record(record)
            helpers.write_file(helpers.recordPath, content)

            msg.untracking_message(obj)
        else:
            msg.nothing_being_tracked()
コード例 #3
0
ファイル: status.py プロジェクト: jaderigby/timeTracking
def execute():
    record = helpers.load_record()

    current = record['current']
    if current == "":
        msg.no_current_project()
    else:
        description = record['projects'][current]['description']
        today = helpers.date_stamp()
        current_time = helpers.time_stamp()
        tt = '00:00'

        tracking = False
        for i in record['projects'][current]['time']:
            if i['end'] == '':
                tracking = True
            if i['start'][:-6] == today:
                s = i['spent']
                if s == '':
                    s = helpers.time_spent(i['start'], current_time)
                tt = helpers.calculate_time(tt, s)

        totalTime = helpers.calculate_total_time(
            record['projects'][current]['time'])

        msg.currentProject(current, description, totalTime, tt, tracking)
コード例 #4
0
ファイル: addProject.py プロジェクト: jaderigby/timeTracking
def execute(PROJECT):
    record = helpers.load_record()

    current = record['current']
    recordedTime = helpers.time_stamp()

    def verify_exists(VAL, RECORD):
        for item in record['projects']:
            if item == VAL:
                return True
        return False

    if verify_exists(PROJECT, record):
        print "Switching to Project: {}".format(PROJECT)
        record['current'] = PROJECT

        content = helpers.glue_updated_record(record)
        helpers.write_file(helpers.recordPath, content)
    else:
        record['current'] = PROJECT
        record['projects'][PROJECT] = helpers.create_new_project(recordedTime)
        record['projects'][PROJECT]['description'] = helpers.add_a_description(
        )

        content = helpers.glue_updated_record(record)
        helpers.write_file(helpers.recordPath, content)
コード例 #5
0
ファイル: jiraLog.py プロジェクト: jaderigby/timeTracking
def execute():
    record = helpers.load_record()

    current = record['current']

    workLogList = helpers.work_log_list(record, current)
    if len(workLogList) != 0:
        jira = JIRA('https://contentwatch.atlassian.net',
                    basic_auth=(passwordHide['username'],
                                passwordHide['password']))
        issue = jira.issue(current)
        msg.jira_item_being_logged(issue.fields.summary)

        print "----------------------------------"
        for item in workLogList:
            print 'Time:   {time}'.format(
                time=helpers.time_worked(item['spent']))
        print
        for item in record['projects'][current]['time']:
            if item['spent'] != '':
                if 'jira_recorded' in item:
                    if item['jira_recorded'] == 'False':
                        timeWorked = helpers.time_worked(item['spent'])
                        if timeWorked != '0h 00m':
                            # print helpers.jira_start_date_format2(item['start'])
                            jira.add_worklog(current,
                                             timeSpent=timeWorked,
                                             timeSpentSeconds=None,
                                             adjustEstimate=None,
                                             newEstimate=None,
                                             reduceBy=None,
                                             comment=helpers.work_log_comment(
                                                 item['spent_date'],
                                                 timeWorked),
                                             started=None,
                                             user=None)
                        item['jira_recorded'] = 'True'
                else:
                    timeWorked = helpers.time_worked(item['spent'])
                    if timeWorked != '0h 00m':
                        # print helpers.jira_start_date_format2(item['start'])
                        jira.add_worklog(current,
                                         timeSpent=timeWorked,
                                         timeSpentSeconds=None,
                                         adjustEstimate=None,
                                         newEstimate=None,
                                         reduceBy=None,
                                         comment=helpers.work_log_comment(
                                             item['spent_date'], timeWorked),
                                         started=None,
                                         user=None)
                    item['jira_recorded'] = 'True'
        content = helpers.glue_updated_record(record)
        helpers.write_file(helpers.recordPath, content)
        print
        msg.process_completed()
    else:
        msg.nothing_to_log()
コード例 #6
0
def execute():
	record = helpers.load_record()

	selection = helpers.select_project(record)

	if selection != 'x':
		record['current'] = selection

		content = helpers.glue_updated_record(record)

		helpers.write_file(helpers.recordPath, content)

		msg.switching_project(selection)

	else:
		msg.process_completed()
コード例 #7
0
def execute():
	record = helpers.load_record()

	while True:
		projectSelection = msg.select_date_for_times(record)

		if projectSelection is 'x':
			break
		else:
			dates = helpers.compile_date_list(record)
			chosenDate = dates[int(projectSelection) - 1]
			newList = helpers.collect_projects_by_date(dates, record['projects'])

			msg.show_projects_for_date(newList, chosenDate)

	print
	print '[Finished]'
	print
コード例 #8
0
ファイル: allTime.py プロジェクト: jaderigby/timeTracking
def execute():
    record = helpers.load_record()

    while True:
        projectSelection = msg.select_project_for_times(record)

        if projectSelection is 'x':
            break

        projectName = helpers.retrieve_project_name(
            projectSelection, helpers.project_list(record))

        totalTimeDict = helpers.calculate_total_time_daily(
            record['projects'][projectName]['time'])
        totalTime = helpers.calculate_total_time(
            record['projects'][projectName]['time'])

        print '''
===========================================

{title} ({total})
Description: {description}

Breakdown by Day:
-----------------'''.format(
            title=projectName,
            description=record['projects'][projectName]['description'],
            total=totalTime)
        i = 0
        for item in totalTimeDict:
            if item['date'] == '':
                item['date'] = "-- {} --".format(helpers.date_stamp())
                item['spent'] = "currently tracking"
            i += 1
            print '''
{itemNumber}.  Date:{date}
    Spent: {spent}

===========================================
'''.format(itemNumber=i, date=item['date'], spent=item['spent'])
    print
    print '[Finished]'
    print
コード例 #9
0
def execute():
    record = helpers.load_record()

    projectName = record['current']

    if projectName == "":
        msg.no_current_project()
    else:
        totalTimeDict = helpers.calculate_total_time_daily(
            record['projects'][projectName]['time'])
        totalTime = helpers.calculate_total_time(
            record['projects'][projectName]['time'])

        print '''
===========================================

{title} ({total})
Description: {description}

Breakdown by Day:
-----------------'''.format(
            title=projectName,
            description=record['projects'][projectName]['description'],
            total=totalTime)
        i = 0
        for item in totalTimeDict:
            if item['date'] == '':
                item['date'] = "-- {} --".format(helpers.date_stamp())
                item['spent'] = "currently tracking"
            i += 1
            print '''
{itemNumber}.  Date: {date}
    Spent: {spent}'''.format(itemNumber=i,
                             date=item['date'],
                             spent=item['spent'])
        print
        print '[Finished]'
        print "==========================================="
        print
コード例 #10
0
def execute():
    record = helpers.load_record()

    selection = helpers.select_project(record)

    if selection != 'x':
        entry, entryIndex = helpers.select_entry(record, selection)
        if entry != 'x':
            selectedEdit = input('''
PROJECT: {}
ENTRY:
         [1] start - {}
         [2] end -   {}

Select an item to change: '''.format(selection, entry['start'], entry['end']))


# 	editWhich = input('''
# [1] Date
# [2] Time
# [3] Both
#
# [x] Exit
#
# : ''')
        if selectedEdit is 1:
            record['projects'][selection]['time'][
                int(entryIndex) - 1]['start'] = raw_input(
                    '''Enter correct start time [{}]: '''.format(
                        entry['start']))

            start = record['projects'][selection]['time'][int(entryIndex) -
                                                          1]['start']
            end = record['projects'][selection]['time'][int(entryIndex) -
                                                        1]['end']
            record['projects'][selection]['time'][
                int(entryIndex) -
                1]['spent'] = helpers.calculate_time_by_start_stop(start, end)
        elif selectedEdit is 2:
            record['projects'][selection]['time'][
                int(entryIndex) - 1]['end'] = raw_input(
                    '''Enter correct end time [{}]: '''.format(entry['end']))
            newDate = record['projects'][selection]['time'][int(entryIndex) -
                                                            1]['end'][:-6]
            record['projects'][selection]['time'][int(entryIndex) -
                                                  1]['spent_date'] = newDate

            start = record['projects'][selection]['time'][int(entryIndex) -
                                                          1]['start'][11:]
            end = record['projects'][selection]['time'][int(entryIndex) -
                                                        1]['end'][11:]
            print("start: {}  end: {}".format(start, end))
            print helpers.calculate_time_by_start_stop(start, end)
            record['projects'][selection]['time'][
                int(entryIndex) -
                1]['spent'] = helpers.calculate_time_by_start_stop(start, end)

        confirmChange = raw_input('''
You are about to change the entry to:
---------------------------------------------------

PROJECT:    "{}"

START:      {}
END:        {}
SPENT_DATE: {}
SPENT:      {}

Confirm Change (y/n): '''.format(
            selection, record['projects'][selection]['time'][int(entryIndex) -
                                                             1]['start'],
            record['projects'][selection]['time'][int(entryIndex) - 1]['end'],
            record['projects'][selection]['time'][int(entryIndex) -
                                                  1]['spent_date'],
            record['projects'][selection]['time'][int(entryIndex) -
                                                  1]['spent']))
        if confirmChange is 'y':
            content = helpers.glue_updated_record(record)

            helpers.write_file(helpers.recordPath, content)

            print('\nThe entry has been changed!\n')

        elif confirmChange is 'n':
            print('\nChange Aborted!\n')

        msg.process_completed()

    else:
        msg.process_completed()