ui.py

changeset 20
fdfbe5d7b677
parent 19
f9ce2442f14f
child 21
c36e549a7f12
equal deleted inserted replaced
19:f9ce2442f14f 20:fdfbe5d7b677
32 MB = float(KB ** 2) # 1,048,576 32 MB = float(KB ** 2) # 1,048,576
33 GB = float(KB ** 3) # 1,073,741,824 33 GB = float(KB ** 3) # 1,073,741,824
34 TB = float(KB ** 4) # 1,099,511,627,776 34 TB = float(KB ** 4) # 1,099,511,627,776
35 35
36 if B < KB: 36 if B < KB:
37 return '{0} {1}B'.format(B) 37 return '{0}B'.format(B)
38 elif KB <= B < MB: 38 elif KB <= B < MB:
39 return '{0:.2f}KB'.format(B/KB) 39 return '{0:.2f}KB'.format(B/KB)
40 elif MB <= B < GB: 40 elif MB <= B < GB:
41 return '{0:.2f}MB'.format(B/MB) 41 return '{0:.2f}MB'.format(B/MB)
42 elif GB <= B < TB: 42 elif GB <= B < TB:
74 # Operation running 74 # Operation running
75 progress='' 75 progress=''
76 if 'progress_current' in status and 'progress_total' in status: 76 if 'progress_current' in status and 'progress_total' in status:
77 progress=' %d%%' % (status.progress_current/status.progress_total) 77 progress=' %d%%' % (status.progress_current/status.progress_total)
78 elif 'original_size' in status and 'deduplicated_size' in status: 78 elif 'original_size' in status and 'deduplicated_size' in status:
79 progress=' %s O %s D' % (humanbytes(status.original_size), 79 progress=' %s→%s' % (humanbytes(status['original_size']),
80 humanbytes(status.deduplicated_size)) 80 humanbytes(status['deduplicated_size']))
81 title="%s (running: %s%s)" % (status['name'], status['operation'], progress) 81 title="%s (running: %s%s)" % (status['name'], status['operation'], progress)
82 state=ACTIVE 82 state=ACTIVE
83 else: # status['type']=='nothing': 83 else: # status['type']=='nothing':
84 # Should be unscheduled, nothing running 84 # Should be unscheduled, nothing running
85 title=status['name'] 85 title=status['name']
120 menu=[] 120 menu=[]
121 state=INACTIVE 121 state=INACTIVE
122 for index in range(len(self.backups)): 122 for index in range(len(self.backups)):
123 b=self.backups[index] 123 b=self.backups[index]
124 title, this_state=make_title(self.statuses[index]) 124 title, this_state=make_title(self.statuses[index])
125 logging.info('TITLE: %s' % title)
126 # Python closures suck dog's balls... 125 # Python closures suck dog's balls...
127 # first and the last program I write in Python until somebody 126 # first and the last program I write in Python until somebody
128 # fixes this brain damage 127 # fixes this brain damage
129 cbm=lambda sender, _b=b: self.__menu_select_backup(sender, _b) 128 cbm=lambda sender, _b=b: self.__menu_select_backup(sender, _b)
130 item=rumps.MenuItem(title, callback=cbm) 129 item=rumps.MenuItem(title, callback=cbm)

mercurial