fix version parsing

This commit is contained in:
dadav 2020-01-16 18:52:40 +01:00
parent f154b97ab9
commit afc3636939
10 changed files with 23 additions and 10 deletions

@ -115,7 +115,7 @@ if __name__ == '__main__':
args = parser.parse_args() args = parser.parse_args()
if args.version: if args.version:
print(pwnagotchi.version) print(pwnagotchi.__version__)
sys.exit(0) sys.exit(0)
config = utils.load_config(args) config = utils.load_config(args)

@ -218,7 +218,7 @@
- name: fetch pwnagotchi version - name: fetch pwnagotchi version
set_fact: set_fact:
pwnagotchi_version: "{{ lookup('file', '/usr/local/src/pwnagotchi/pwnagotchi/__init__.py') | replace('\n', ' ') | regex_replace('.*version.*=.*''([0-9]+\\.[0-9]+\\.[0-9]+[A-Za-z0-9]*)''.*', '\\1') }}" pwnagotchi_version: "{{ lookup('file', '/usr/local/src/pwnagotchi/pwnagotchi/_version.py') | regex_replace('.*__version__.*=.*''([0-9]+\\.[0-9]+\\.[0-9]+[A-Za-z0-9]*)''.*', '\\1') }}"
- name: pwnagotchi version found - name: pwnagotchi version found
debug: debug:

@ -6,7 +6,7 @@ import re
import pwnagotchi.ui.view as view import pwnagotchi.ui.view as view
import pwnagotchi import pwnagotchi
version = '1.4.3' from _version import __version__
_name = None _name = None

1
pwnagotchi/_version.py Normal file

@ -0,0 +1 @@
__version__ = '1.4.3'

@ -49,7 +49,7 @@ class Agent(Client, Automata, AsyncAdvertiser, AsyncTrainer):
if not os.path.exists(config['bettercap']['handshakes']): if not os.path.exists(config['bettercap']['handshakes']):
os.makedirs(config['bettercap']['handshakes']) os.makedirs(config['bettercap']['handshakes'])
logging.info("%s@%s (v%s)", pwnagotchi.name(), self.fingerprint(), pwnagotchi.version) logging.info("%s@%s (v%s)", pwnagotchi.name(), self.fingerprint(), pwnagotchi.__version__)
for _, plugin in plugins.loaded.items(): for _, plugin in plugins.loaded.items():
logging.debug("plugin '%s' v%s", plugin.__class__.__name__, plugin.__version__) logging.debug("plugin '%s' v%s", plugin.__class__.__name__, plugin.__version__)

@ -85,7 +85,7 @@ def update_data(last_session):
}, },
'uname': subprocess.getoutput("uname -a"), 'uname': subprocess.getoutput("uname -a"),
'brain': brain, 'brain': brain,
'version': pwnagotchi.version 'version': pwnagotchi.__version__
} }
logging.debug("updating grid data: %s" % data) logging.debug("updating grid data: %s" % data)

@ -17,7 +17,7 @@ class AsyncAdvertiser(object):
self._keypair = keypair self._keypair = keypair
self._advertisement = { self._advertisement = {
'name': pwnagotchi.name(), 'name': pwnagotchi.name(),
'version': pwnagotchi.version, 'version': pwnagotchi.__version__,
'identity': self._keypair.fingerprint, 'identity': self._keypair.fingerprint,
'face': faces.FRIEND, 'face': faces.FRIEND,
'pwnd_run': 0, 'pwnd_run': 0,

@ -183,7 +183,7 @@ class AutoUpdate(plugins.Plugin):
to_check = [ to_check = [
('bettercap/bettercap', parse_version('bettercap -version'), True, 'bettercap'), ('bettercap/bettercap', parse_version('bettercap -version'), True, 'bettercap'),
('evilsocket/pwngrid', parse_version('pwngrid -version'), True, 'pwngrid-peer'), ('evilsocket/pwngrid', parse_version('pwngrid -version'), True, 'pwngrid-peer'),
('evilsocket/pwnagotchi', pwnagotchi.version, False, 'pwnagotchi') ('evilsocket/pwnagotchi', pwnagotchi.__version__, False, 'pwnagotchi')
] ]
for repo, local_version, is_native, svc_name in to_check: for repo, local_version, is_native, svc_name in to_check:

@ -136,7 +136,7 @@ class View(object):
return self._state.get(key) return self._state.get(key)
def on_starting(self): def on_starting(self):
self.set('status', self._voice.on_starting() + ("\n(v%s)" % pwnagotchi.version)) self.set('status', self._voice.on_starting() + ("\n(v%s)" % pwnagotchi.__version__))
self.set('face', faces.AWAKE) self.set('face', faces.AWAKE)
def on_ai_ready(self): def on_ai_ready(self):

@ -4,6 +4,7 @@ from setuptools import setup, find_packages
import os import os
import glob import glob
import shutil import shutil
import re
def install_file(source_filename, dest_filename): def install_file(source_filename, dest_filename):
@ -42,16 +43,27 @@ def installer():
# for people updating https://github.com/evilsocket/pwnagotchi/pull/551/files # for people updating https://github.com/evilsocket/pwnagotchi/pull/551/files
os.system("systemctl enable fstrim.timer") os.system("systemctl enable fstrim.timer")
def version(version_file):
with open(version_file, 'rt') as vf:
version_file_content = vf.read()
version_match = re.search(r"__version__\s*=\s*[\"\']([^\"\']+)", version_file_content)
if version_match:
return version_match.groups()[0]
return None
installer() installer()
with open('requirements.txt') as fp: with open('requirements.txt') as fp:
required = [line.strip() for line in fp if line.strip() != ""] required = [line.strip() for line in fp if line.strip() != ""]
import pwnagotchi VERSION_FILE = 'pwnagotchi/_version.py'
pwnagotchi_version = version(VERSION_FILE)
setup(name='pwnagotchi', setup(name='pwnagotchi',
version=pwnagotchi.version, version=pwnagotchi_version,
description='(⌐■_■) - Deep Reinforcement Learning instrumenting bettercap for WiFI pwning.', description='(⌐■_■) - Deep Reinforcement Learning instrumenting bettercap for WiFI pwning.',
author='evilsocket && the dev team', author='evilsocket && the dev team',
author_email='evilsocket@gmail.com', author_email='evilsocket@gmail.com',