kootenpv / brightml

Convenient Machine-Learned Auto Brightness (Linux)
MIT License
120 stars 4 forks source link

hardcoded username? #1

Closed tshirtman closed 6 years ago

tshirtman commented 6 years ago

just pip installed it, along with whereami (and scipy, that wasn't mentionned as a dep apparently), but when i start it, get this error

gabriel@gryphon:~> sudo ~/.local/bin/brightml 
Traceback (most recent call last):
  File "/home/gabriel/.local/bin/brightml", line 11, in <module>
    sys.exit(main())
  File "/home/gabriel/.local/lib/python3.5/site-packages/brightml/__main__.py", line 6, in main
    main()
  File "/home/gabriel/.local/lib/python3.5/site-packages/brightml/brightml.py", line 71, in main
    bml = Brightml(d)
  File "/home/gabriel/.local/lib/python3.5/site-packages/brightml/brightml.py", line 23, in __init__
    self.bm = BrightnessManager()
  File "/home/gabriel/.local/lib/python3.5/site-packages/brightml/brightness.py", line 62, in __init__
    self.adapters = [x for x in self.adapters if x.is_valid]
  File "/home/gabriel/.local/lib/python3.5/site-packages/brightml/brightness.py", line 62, in <listcomp>
    self.adapters = [x for x in self.adapters if x.is_valid]
  File "/home/gabriel/.local/lib/python3.5/site-packages/brightml/brightness.py", line 45, in is_valid
    self.brightness += 1
  File "/home/gabriel/.local/lib/python3.5/site-packages/brightml/brightness.py", line 22, in brightness
    self._set_brightness(value)
  File "/home/gabriel/.local/lib/python3.5/site-packages/brightml/brightness.py", line 29, in _set_brightness
    with open("/home/pascal/.brightml/last_updated/update", "w") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/pascal/.brightml/last_updated/update'

As you can see, the ~/ directory doesn't match my user.

kootenpv commented 6 years ago

Thanks for mentioning it! I added scipy as dependency. Please try update, or uninstall and install --no-cache!

pip install -U brightml
tshirtman commented 6 years ago

Ok, the path is indeed fixed, but it seems something is missing to automatically create the ~/.brightml content

Traceback (most recent call last):
  File "/home/gabriel/.local/bin/brightml", line 11, in <module>
    sys.exit(main())
  File "/home/gabriel/.local/lib/python3.5/site-packages/brightml/__main__.py", line 6, in main
    main()
  File "/home/gabriel/.local/lib/python3.5/site-packages/brightml/brightml.py", line 71, in main
    bml = Brightml(d)
  File "/home/gabriel/.local/lib/python3.5/site-packages/brightml/brightml.py", line 23, in __init__
    self.bm = BrightnessManager()
  File "/home/gabriel/.local/lib/python3.5/site-packages/brightml/brightness.py", line 68, in __init__
    self.adapters = [x for x in self.adapters if x.is_valid]
  File "/home/gabriel/.local/lib/python3.5/site-packages/brightml/brightness.py", line 68, in <listcomp>
    self.adapters = [x for x in self.adapters if x.is_valid]
  File "/home/gabriel/.local/lib/python3.5/site-packages/brightml/brightness.py", line 51, in is_valid
    self.brightness += 1
  File "/home/gabriel/.local/lib/python3.5/site-packages/brightml/brightness.py", line 25, in brightness
    self._set_brightness(value)
  File "/home/gabriel/.local/lib/python3.5/site-packages/brightml/brightness.py", line 32, in _set_brightness
    with open(self.update_path, "w") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/gabriel/.brightml/last_updated/update'
13:43:35 21/10/17 red argv[1] 94% 1 701

tried creating the path

gabriel@gryphon:~> mkdir -p .brightml/last_updated/

but still not working

gabriel@gryphon:~> sudo ~/.local/bin/brightml
[BrightnessAdapter(path='/sys/class/backlight/intel_backlight/')]
Traceback (most recent call last):
  File "/home/gabriel/.local/bin/brightml", line 11, in <module>
    sys.exit(main())
  File "/home/gabriel/.local/lib/python3.5/site-packages/brightml/__main__.py", line 6, in main
    main()
  File "/home/gabriel/.local/lib/python3.5/site-packages/brightml/brightml.py", line 71, in main
    bml = Brightml(d)
  File "/home/gabriel/.local/lib/python3.5/site-packages/brightml/brightml.py", line 25, in __init__
    self.pipeline_clf = get_classifier_pipeline(None)
  File "/home/gabriel/.local/lib/python3.5/site-packages/brightml/pipeline.py", line 106, in get_classifier_pipeline
    data = get_training_data(path)
  File "/home/gabriel/.local/lib/python3.5/site-packages/brightml/utils.py", line 43, in get_training_data
    data = pd.read_json(path, lines=True)
  File "/home/gabriel/.local/lib/python3.5/site-packages/pandas/io/json/json.py", line 354, in read_json
    date_unit).parse()
  File "/home/gabriel/.local/lib/python3.5/site-packages/pandas/io/json/json.py", line 422, in parse
    self._parse_no_numpy()
  File "/home/gabriel/.local/lib/python3.5/site-packages/pandas/io/json/json.py", line 639, in _parse_no_numpy
    loads(json, precise_float=self.precise_float), dtype=None)
ValueError: Expected object or value
kootenpv commented 6 years ago

Thanks, I can solve it now :)!

I needed to ensure the path exists in 2 places of the code. Since it is async/event base, it is even more important.

Also now dealing with the lack of training examples.

Please do one more update, it is on pypi. It should work fine then!

tshirtman commented 6 years ago

Indeed, no more crashing, letting it run and adjusting the level, will see how it goes!

Thank you!