I have this python script that I want in include in a snap. Basically, I’m connecting to a outside server (that part works) and I receive a zip file, and I wish to unzip it and save those files across reboots.
This is AWS cert files for an Iot device, so I want these files to be backed up and restored, so SNAP_DATA is what I want to use I think, but have no clue as to go about doing so. Do I refer to SNAP_DATA in the script itself, or just in yaml?
Thanks a million!
file = open('serial_certs.zip', 'wb+') while data != bytes(''.encode()): file.write(data) data = self.sock.recv(1024) self.sock.close() file.close() with zipfile.ZipFile('serial_certs.zip', 'r') as zip_ref: zip_ref.extractall(('serial_certs'))
apps: identity: command: python3 $SNAP/tcp_client.py daemon: simple restart-condition: on-failure plugs: [home, network, network-bind] environment: LC_ALL: C.UTF-8 LANG: C.UTF-8 parts: identity: plugin: dump source: ./app/identity