File size: 1,542 Bytes
7a71a69 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
import memdam.recorder.config
class User(object):
"""
This interface represents the user.
All interaction with the user, including input and output, prompts, display, etc, should go
through here.
"""
def prompt_user(self, prompt_text):
"""
Ask the user for some text.
"""
def main_loop(self, start, shutdown):
"""
This should run the underlying gui event main loop or whatever else is the driving logic for
the program.
:param start: call this function to start the regular processing logic
:type start: function()
:param shutdown: call this function to shutdown cleanly
:type shutdown: function()
:returns: exit code
:rtype: int
"""
def create_initial_config(self, filename, collector_config):
"""
The user must define initial values for things like username, password, etc, and can use
default values otherwise.
This will be pretty much the first thing called when the application runs for the first
time. Will be called when the main_loop is NOT running.
"""
default_config = memdam.recorder.config.get_default_config(filename, collector_config)
username = self.prompt_user(u'Please enter your username')
password = self.prompt_user(u'Please enter your password')
new_config = memdam.recorder.config.Config(filename=filename, password=password, username=username, **default_config.data)
new_config.save()
|