Beispiel #1
0
def show_pickle():
    """Load the lecture pickle and display it on a Tk message dialog."""
    mydict = open_pickle()
    msg = ''
    line_pat = '%s: %s\n'
    for key, value in mydict.iteritems():
        curline = line_pat % (key, value)
        msg += curline
    W = tk_msg_dialog.myWindow(msg)
Beispiel #2
0
def reset_pickle():
    """Use this at the beginning of a lecture to set the pickle to
    slide 0 of the correct class based on the time and day of the
    week."""
    debug = 4
    #debugging - set to first day of class
    if debug == 1:
        now = time.strptime('08/23/10 8:55', '%m/%d/%y %H:%M')
    elif debug == 2:
        now = time.strptime('08/24/10 12:15', '%m/%d/%y %H:%M')
    elif debug == 3:
        now = time.strptime('09/08/10 13:25', '%m/%d/%y %H:%M')
    elif debug == 4:
        now = time.strptime('01/13/11 19:25', '%m/%d/%y %H:%M')
    else:
        now = time.localtime()
    
    mydict = {}
    mydict['current_slide'] = 0
    mydict['outline_slide'] = 0
    mydict['date_stamp'] = time.strftime('%m/%d/%y', now)
    date_str = time.strftime('%m_%d_%y', now)

    found = False
    if (now.tm_wday in [0,2]) and (now.tm_hour < 11):
        found = True
        course = '458'
        root = '/home/ryan/siue/classes/mechatronics/%i/lectures/%s' % \
               (now.tm_year, date_str)
    elif (now.tm_wday in [1,3]) and (11 < now.tm_hour < 15):
        found = True
        course = '482'
        root = '/home/ryan/siue/classes/482/%i/lectures/%s' % \
               (now.tm_year, date_str)
    elif (now.tm_wday in [1,3]) and (18 < now.tm_hour < 22):
        found = True
        course = '592'
        root = '/home/ryan/siue/classes/nonlinear_controls/%i/lectures/%s' % \
               (now.tm_year, date_str)
    if (now.tm_wday == 2) and (now.tm_hour > 12):
        found = True
        course = '492'
        root = '/home/ryan/siue/classes/mobile_robotics/%i/lectures/%s' % \
               (now.tm_year, date_str)


    if found:
        mydict['course_num'] = course
        mydict['pat'] = 'ME' + course + '_' + date_str + '_%0.4i.xcf'
        mydict['search_pat'] = 'ME' + course +'_' + date_str
        mydict['lecture_path'] = rwkos.FindFullPath(root)
        save_pickle(mydict)
    else:
        msg = 'Could not determine the course\n' + \
              'based on the current day/time.\n' + \
              '\n' + \
              'now.tm_wday = %s\n' % now.tm_wday + \
              'now.tm_hour = %s\n' % now.tm_hour + \
              '\n' + \
              'Run the script gimp_lecture_prep.py.'
        W = tk_msg_dialog.myWindow(msg)