-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Development: Issue#18 (Sourcery refactored) #20
base: development---signed
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,9 +28,7 @@ def init_lcd(): | |
lcd_columns = 16 | ||
lcd_rows = 2 | ||
i2c = busio.I2C(board.SCL, board.SDA) | ||
lcd = character_lcd.Character_LCD_RGB_I2C(i2c, lcd_columns, lcd_rows) | ||
|
||
return lcd | ||
return character_lcd.Character_LCD_RGB_I2C(i2c, lcd_columns, lcd_rows) | ||
|
||
def init_gpio(): | ||
''' | ||
|
@@ -90,7 +88,7 @@ def check_usb(): | |
connected_usb = usb.core.find(find_all=True) | ||
|
||
#Check if no devices are connected | ||
if connected_usb == None: | ||
if connected_usb is None: | ||
Comment on lines
-93
to
+91
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
lcd.clear() | ||
lcd.message = "No devices found" | ||
raise ValueError('No Devices Found.') | ||
|
@@ -104,7 +102,7 @@ def check_usb(): | |
usb_device_vendorID = hex(device.idVendor) | ||
usb_device_productID = hex(device.idProduct) | ||
device_list[usb_device] = usb_device_vendorID, usb_device_productID | ||
|
||
lcd.clear() | ||
lcd.message = "Devices found" | ||
time.sleep(0.5) | ||
|
@@ -160,14 +158,12 @@ def mount_usb(dbl, dil, mbl, mil, backup_name, input_name): | |
|
||
check_path_backup = (mbl + 'backup') | ||
check_path_input = (mil + 'source') | ||
|
||
lcd.clear() | ||
lcd.message = "Mounting Devices" | ||
time.sleep(0.5) | ||
|
||
if os.path.exists(check_path_backup): | ||
pass | ||
else: | ||
if not os.path.exists(check_path_backup): | ||
Comment on lines
-163
to
+166
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
#make dir for mount point | ||
makedir_backup = ('mkdir ' + mbl + 'backup') | ||
os.system(makedir_backup) | ||
|
@@ -181,9 +177,7 @@ def mount_usb(dbl, dil, mbl, mil, backup_name, input_name): | |
lcd.message = "Backup Mounted" | ||
time.sleep(0.5) | ||
|
||
if os.path.exists(check_path_input): | ||
pass | ||
else: | ||
if not os.path.exists(check_path_input): | ||
#make dir for mount point | ||
makedir_input = ('mkdir ' + mil + 'source') | ||
os.system(makedir_input) | ||
|
@@ -192,7 +186,7 @@ def mount_usb(dbl, dil, mbl, mil, backup_name, input_name): | |
#make mount point for input usb | ||
input_command = ('sudo mount -t auto ' + dil + ' ' + mil + 'source') | ||
os.system(input_command) | ||
|
||
lcd.clear() | ||
lcd.message = "Source Mounted" | ||
time.sleep(0.5) | ||
|
@@ -306,38 +300,38 @@ def wifi_off(): | |
|
||
lcd.clear() | ||
lcd.message = "Insert USB's\nPress Select" | ||
|
||
device_add = True | ||
while device_add == True: | ||
while device_add: | ||
#shutdown RPI | ||
if lcd.down_button: | ||
lcd.clear() | ||
shutdown() | ||
|
||
#reboot RPI | ||
if lcd.up_button: | ||
lcd.clear() | ||
restart() | ||
|
||
Comment on lines
-309
to
+315
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
#perform USB check | ||
if lcd.select_button: | ||
#get connected usb devices | ||
usb_device = check_usb() | ||
|
||
#validate if backup and input devices are connected | ||
backup_usb_device_vendor, input_usb_device_vendor, backup_usb_device_product, input_usb_device_product = verify_usb(usb_device, backup_device, input_device) | ||
|
||
#mount USB | ||
mount_usb(dev_backup_loc, dev_input_loc, mnt_backup_loc, mnt_input_loc, backup_device, input_device) | ||
|
||
lcd.clear() | ||
lcd.message = "Press RB to\nbegin backup" | ||
|
||
if lcd.right_button: | ||
#check if /mnt/backup and /mnt/source exist | ||
verify_backup_loc = mnt_backup_loc + 'backup' | ||
verify_source_loc = mnt_input_loc + 'source' | ||
|
||
if os.path.exists(verify_backup_loc) and os.path.exists(verify_source_loc): | ||
#rsync backup -> right_button | ||
run_autobackup(dev_backup_loc, dev_input_loc, mnt_backup_loc, mnt_input_loc, backup_device, input_device) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
init_lcd
refactored with the following changes:inline-immediately-returned-variable
)