Nojoc.py can't start

Issue #26 new
Daniel created an issue

I've gotten all prerequisites and I even tried installing a fresh Debian install on another computer, same problem. First the screen "You made it that far, API is not public bla bla", den it quits with this:

pi@raspberrypi:~/ojoc $ ./nojoc.py -c Vienna,AT
Location specified as Vienna,AT
Traceback (most recent call last):
  File "./nojoc.py", line 718, in <module>
    loop.run()
  File "/usr/lib/python2.7/dist-packages/urwid/main_loop.py", line 274, in run
    self.screen.run_wrapper(self._run)
  File "/usr/lib/python2.7/dist-packages/urwid/raw_display.py", line 268, in run_wrapper
    return fn()
  File "/usr/lib/python2.7/dist-packages/urwid/main_loop.py", line 339, in _run
    self.event_loop.run()
  File "/usr/lib/python2.7/dist-packages/urwid/main_loop.py", line 669, in run
    self._loop()
  File "/usr/lib/python2.7/dist-packages/urwid/main_loop.py", line 702, in _loop
    alarm_callback()
  File "/usr/lib/python2.7/dist-packages/urwid/main_loop.py", line 158, in cb
    callback(self, user_data)
  File "./nojoc.py", line 685, in init_cb
    toplevel_widget = MenuBox(menubar_tags,menues,OJOC.Connection.Connection(citycc=arg))
  File "/home/pi/ojoc/OJOC/Connection.py", line 212, in __init__
    self.device_uid = _get_uid()
  File "/home/pi/ojoc/OJOC/Connection.py", line 637, in _get_uid
    device_uid = keyring.get_password("jodel", "device_uid")
  File "/usr/local/lib/python2.7/dist-packages/keyring/core.py", line 42, in get_password
    return _keyring_backend.get_password(service_name, username)
  File "/usr/local/lib/python2.7/dist-packages/keyring/backends/fail.py", line 23, in get_password
    raise RuntimeError(msg)
RuntimeError: No recommended backend was available. Install the keyrings.alt package if you want to use the non-recommended backends. See README.rst for details.
pi@raspberrypi:~/ojoc $ 

It was from a fresh Raspian Jesse Lite install, Python version is 2.7.9 (does it have to be 2.7.11?). Probably a trivial solution, but I just can't get it to work after +8h...

Comments (4)

  1. Daniel reporter

    Thanks! I've figured some stuff out, first of all installing

    pip install keyrings.alt
    

    solved the RuntimeError so that's nice. What then occurs though is more strange, I start it up and I get this

      File "/usr/local/lib/python2.7/dist-packages/keyrings/alt/file.py", line 94, in keyring_key
        self._init_file()
      File "/usr/local/lib/python2.7/dist-packages/keyrings/alt/file.py", line 101, in _init_file
        self.keyring_key = self._get_new_password()
      File "/usr/local/lib/python2.7/dist-packages/keyrings/alt/file.py", line 55, in _get_new_password
        "Please set a password for your new keyring: ")
      File "/usr/lib/python2.7/getpass.py", line 71, in unix_getpass
        passwd = _raw_input(prompt, stream, input=input)
      File "/usr/lib/python2.7/getpass.py", line 133, in _raw_input
        line = input.readline()
    KeyboardInterrupt
    

    So I need to in the dark (while the "You made it that far!" logo is covering everything) to enter a password. Then every next time it starts I need to do the same thing for the newly set password, but still in the dark. Then afterwords it starts and all works fine. If I instead run ojoc_dumper.py the "Please enter password for encrypted keyring" occurs as a regular terminal text and I do the same procedure, works then too. I haven't tried this on my regular Debian laptop yet if it is the same there.

    Got any knowledge on how to surpass it? Or some good solution to it?

  2. Christian Fibich repo owner

    I pushed branch pre-connect with b96e4a3.

    It creates the OJOC.Connection.Connection object before displaying the splash screen. This should lead to the password prompt being displayed before the splash screen clears the terminal.

    If this solves your problem, I'll merge it.

  3. Daniel reporter

    It probably would solve the issue and allow for a setting of password to the keyring and later on entering it. I solved it "quick and dirty" another way which has worked just fine for my headless system but forgot to comment it here.

    I simply just store the UID in a txt file in the OJOC-directory and fetch it every time I start. Probably not an optimal solution but it works fine for me.

    def _get_uid():
        try:
            uid = open("OJOC/uid.txt", 'r')
            device_uid = uid.read()
        except IOError as e:
            uid = open("OJOC/uid.txt", 'w')
            device_uid = "0"
            print "Error in getting device_uid"
    
        if len(device_uid) != 64:
            try:
                # device UID is a SHA256 hash
                # generate a random one here
                print "Generating new device_uid"
                id_bytes = os.urandom(32)
                id_bytes_str = ["%02x" % (ord(byte)) for byte in id_bytes]
                device_uid = ''.join(id_bytes_str)
                uid.write(device_uid)
        uid.close()
        return device_uid
    
  4. Log in to comment