Compare commits

...

2 Commits

Author SHA1 Message Date
8edb0fdaa4 2.7.5 2024-01-21 11:33:22 +01:00
b557768159 Fix gdrivesync.py 2024-01-21 11:32:39 +01:00
3 changed files with 9 additions and 8 deletions

View File

@ -1 +1 @@
__version__ = '2.7.4' __version__ = '2.7.5'

View File

@ -59,7 +59,8 @@ def load(config, agent, epoch, from_disk=True):
return a2c return a2c
except Exception as e: except Exception as e:
logging.exception("[AI] error while starting AI (%s)", e) logging.info("[AI] Error while starting AI")
logging.debug("[AI] error while starting AI (%s)", e)
logging.info("[AI] Deleting brain and restarting.") logging.info("[AI] Deleting brain and restarting.")
os.system("rm /root/brain.nn && service pwnagotchi restart") os.system("rm /root/brain.nn && service pwnagotchi restart")

View File

@ -14,7 +14,7 @@ import zipfile
class GdriveSync(plugins.Plugin): class GdriveSync(plugins.Plugin):
__author__ = '@jayofelony' __author__ = '@jayofelony'
__version__ = '1.1' __version__ = '1.2'
__license__ = 'GPL3' __license__ = 'GPL3'
__description__ = 'A plugin to backup various pwnagotchi files and folders to Google Drive. Once every hour from loading plugin.' __description__ = 'A plugin to backup various pwnagotchi files and folders to Google Drive. Once every hour from loading plugin.'
@ -34,7 +34,7 @@ class GdriveSync(plugins.Plugin):
'/etc/pwnagotchi' '/etc/pwnagotchi'
] ]
def on_loaded(self, agent): def on_loaded(self):
""" """
Called when the plugin is loaded Called when the plugin is loaded
""" """
@ -182,15 +182,15 @@ class GdriveSync(plugins.Plugin):
logging.info("[gdrivesync] new handshake captured, backing up to gdrive") logging.info("[gdrivesync] new handshake captured, backing up to gdrive")
if self.options['backupfiles'] is not None: if self.options['backupfiles'] is not None:
self.backupfiles = self.backupfiles + self.options['backupfiles'] self.backupfiles = self.backupfiles + self.options['backupfiles']
self.backup_files(self.backupfiles, '/backup') self.backup_files(self.backupfiles, '/home/pi/backup')
# Create a zip archive of the /backup folder # Create a zip archive of the /backup folder
zip_file_path = os.path.join('/home/pi', 'backup.zip') zip_file_path = os.path.join('/home/pi', 'backup.zip')
with zipfile.ZipFile(zip_file_path, 'w') as zip_ref: with zipfile.ZipFile(zip_file_path, 'w') as zip_ref:
for root, dirs, files in os.walk('/backup'): for root, dirs, files in os.walk('/home/pi/backup'):
for file in files: for file in files:
file_path = os.path.join(root, file) file_path = os.path.join(root, file)
arcname = os.path.relpath(file_path, '/backup') arcname = os.path.relpath(file_path, '/home/pi/backup')
zip_ref.write(file_path, arcname=arcname) zip_ref.write(file_path, arcname=arcname)
# Upload the zip archive to Google Drive # Upload the zip archive to Google Drive
@ -199,7 +199,7 @@ class GdriveSync(plugins.Plugin):
# Cleanup the local zip file # Cleanup the local zip file
os.remove(zip_file_path) os.remove(zip_file_path)
os.remove("/backup") shutil.rmtree("/home/pi/backup")
self.status.update() self.status.update()
display = agent.view() display = agent.view()
display.update(force=True, new_data={'Backing up to gdrive ...'}) display.update(force=True, new_data={'Backing up to gdrive ...'})