Skip to content
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

Output class does work now (Sourcery refactored) #11

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ignore the demos directory
demo/
/venv
.idea

# ignore the whitesource tool
.whitesource
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,13 @@ The settings file is comprised of a single `[settings]` field. Under this field
## Troubleshooting

1. If you aren't pulling the git repo into `/home/pi/` then you need to open the `dumper_lcd.py` and/or `dumper_no_lcd.py` and change the source location for the `settings.ini` file.


## Contributors

<table>
<tr>
<td align="center"><a href="https://github.com/schnipdip"><img src="https://avatars1.githubusercontent.com/u/23109762?s=460&u=1ab3d6ad58d06fcc1e4775c1afb501dbebf8d58f&v=4" width="100px;" alt=""/><br /><sub><b>Chris Herzog</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/j-freimuth"><img src="https://avatars1.githubusercontent.com/u/47719233?s=460&v=4" width="100px;" alt=""/><br /><sub><b>Joe Freimuth</b></sub></a><br /></td>
</tr>
</table>
Empty file added linux/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion linux/dump_service_lcd.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ After=mnt-source.mount

[Service]
Type=idle
ExecStart=/usr/bin/sudo /usr/bin/python3 /home/pi/dump/linux/dumper/dumper_lcd.py
ExecStart=/usr/bin/sudo /usr/bin/python3 /home/pi/dump/linux/dumper/dumper.py lcd
Restart=on-failure

[Install]
Expand Down
2 changes: 1 addition & 1 deletion linux/dump_service_no_lcd.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ After=mnt-source.mount

[Service]
Type=idle
ExecStart=/usr/bin/sudo /usr/bin/python3 /home/pi/dump/linux/dumper/dumper_no_lcd.py
ExecStart=/usr/bin/sudo /usr/bin/python3 /home/pi/dump/linux/dumper/dumper.py monitor
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are going to remove this functionality. We don't have to make any changes, in fact we should probably just remove these no_lcd. files.

Restart=on-failure

[Install]
Expand Down
Empty file added linux/dumper/__init__.py
Empty file.
84 changes: 41 additions & 43 deletions linux/dumper/dumper_lcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

def init_lcd():
'''
Params: lcd_columns - number of culumns the LCD Screen has (int)
lcd_rows - number of rwos the LCD Screen has (int)
Params: lcd_columns - number of columns the LCD Screen has (int)
lcd_rows - number of rows the LCD Screen has (int)
i2c - calling i2c program
lcd - setting lcd screen

Expand All @@ -26,9 +26,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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually has to return lcd because it's what allows you to generate messages. Unless since we are decoupling that from main, we can instantiate the LCD in another file.



def get_configparser():
Expand Down Expand Up @@ -77,7 +75,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.')
Expand All @@ -91,15 +89,15 @@ 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)

return device_list

def verify_usb(usb_device_list, backup_device, input_device):
'''
"""
Params: usb_device_list - list of usb devices and their attributes (list)
backup_device - backup device (str)
input_device - input device (str)
Expand All @@ -109,7 +107,7 @@ def verify_usb(usb_device_list, backup_device, input_device):
input_usb_device_product - product id for input device (str)

Returns: backup_usb_device_vendor, input_usb_device_vendor, backup_usb_device_product, input_usb_device_product
'''
"""

backup_device = backup_device.lower()
input_device = input_device.lower()
Expand Down Expand Up @@ -147,14 +145,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)
Expand All @@ -168,9 +164,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)
Expand All @@ -179,7 +173,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)
Expand Down Expand Up @@ -276,49 +270,53 @@ def restart():
while True:
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
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)

#unmount devices
unmount_drives()

device_add = False
else:
lcd.clear()
lcd.message = "Press Select to\nMount USBs"
time.sleep(0.5)


lcd.message = "Press LB to\ncancel"

while device_add:
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)

#unmount devices
unmount_drives()

device_add = False
else:
lcd.clear()
lcd.message = "Press Select to\nMount USBs"
time.sleep(0.5)

if lcd.left_button:
break

Loading