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

Add webcfg-Plugin, Reload config on USR1-sig, SharedConfig class and more... #371

Closed
wants to merge 5 commits into from

Conversation

dadav
Copy link
Contributor

@dadav dadav commented Oct 23, 2019

So, the first idea with the new on_webhook was to create a site in the browser to change the config. The problem was, that the config was all over the place (multiple threads etc.). This is the reason why i created the SharedConfig class. It stores the config in an internal dict, in one place, which allows us to change the config in all threads. What? Change things which are used by multiple threads? Yes, i know. Thats why there is a RWLock on it :)

@dadav
Copy link
Contributor Author

dadav commented Oct 23, 2019

Also, big THX to Azkrath and RoM who helped with the html/javascript stuff^^

@dadav
Copy link
Contributor Author

dadav commented Oct 23, 2019

related issues: #206

dadav and others added 5 commits October 28, 2019 19:30
Fixed typo in meta. Added typeof to ensure correct data types are enforced on inputs. Changed the load values from table to json to also ensure correct outputs.
Added a new button for the save configuration functionality.
@@ -44,16 +44,19 @@ def load_from_file(filename):
return plugin_name, instance


def load_from_path(path, enabled=()):
def load_from_path(path, enabled=list()):
Copy link
Contributor

Choose a reason for hiding this comment

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

So this is (probably) not gonna do what you want here. If you call this function with no 'enabled', argument, python will use the same (mutable) list object every time you call this function. Check this out:

https://docs.python-guide.org/writing/gotchas/

and my simple example:
test.py:

def wtf(arg=list()):
    arg.append('a')
    return arg

print wtf()
print wtf()
jeremy@x1:~/pwnagotchi$ python test.py
['a']
['a', 'a']

Copy link
Contributor Author

Choose a reason for hiding this comment

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

very good catch!

@dadav dadav closed this Nov 8, 2019
@dadav dadav deleted the feature/config_class branch April 1, 2020 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants