From 81596cdb1ef827ccb82c807e5dd9d8d22e5261a8 Mon Sep 17 00:00:00 2001 From: Sourcery AI <> Date: Tue, 3 Nov 2020 01:21:41 +0000 Subject: [PATCH] 'Refactored by Sourcery' --- linux/dumper/dumper_lcd.py | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/linux/dumper/dumper_lcd.py b/linux/dumper/dumper_lcd.py index 325ae16..d343d1d 100644 --- a/linux/dumper/dumper_lcd.py +++ b/linux/dumper/dumper_lcd.py @@ -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: 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): #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,19 +300,19 @@ 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() - + #perform USB check if lcd.select_button: #get connected usb devices @@ -326,18 +320,18 @@ def wifi_off(): #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)