Seeed-Studio / Seeed_Python_ReTerminal

This is a Python library which enables you to use the onboard hardware on the reTerminal.
MIT License
27 stars 6 forks source link

Property `illuminance` not available in pypi library #1

Closed maubuz closed 2 years ago

maubuz commented 2 years ago

Problem

The version of this library installed with pip does not includes the property illuminance from core.py.

Tested in multiple reTerminals.

Steps to reproduce it

  1. Install the library as per official instructions: sudo pip3 install seeed-python-reterminal

  2. Start a python shell, import the module and try to read illuminance data:

    
    import seeed_python_reterminal.core as rt
    print(rt.illuminance)

Traceback (most recent call last): File "", line 1, in AttributeError: '_Core' object has no attribute 'illuminance'


## Potential solution

The library version in pypi is 0.2, published on May 20. 2021, and matches the [version 0.2 in `setup.py`](https://github.com/Seeed-Studio/Seeed_Python_ReTerminal/blob/35e4054cb638f5661111d96e78e722fc427dbd83/setup.py#L8) of this repo.

The illuminance property and example were [added on June 15, 2021.](https://github.com/Seeed-Studio/Seeed_Python_ReTerminal/commit/460b18ebfcebf90f22948c97fdbed848862e07ff) Uploading a new version 0.3 to pypi might be necessary.

## Workaround

1. Find library installation path with `pip3 show seeed-python-reterminal`. Look for `Location: ` path.
2. Go to library installation folder and open `core.py` with CLI editor of choice (eg. nano, vim, etc).
3.  Manually add the two missing lines to `core.py`, match [code in the main branch](https://github.com/Seeed-Studio/Seeed_Python_ReTerminal/commit/460b18ebfcebf90f22948c97fdbed848862e07ff#diff-16dd83bb8fb61e5d85b51669a1b33fdb7a8e4bcb97e1a7bd6f32535d86287597).

```python
   __LIGHT_ILLUMINANCE = "/sys/bus/iio/devices/iio:device0/in_illuminance_input"

  @property
    def illuminance(self):
        return int(self.__read_1st_line_from_file(_Core.__LIGHT_ILLUMINANCE))
matsujirushi commented 2 years ago

Hi @maujac , Thanks for report with detail. You are right.

Ask the person in charge to release the latest code to PyPI.

lakshanthad commented 2 years ago

@matsujirushi @maujac It's done.

https://pypi.org/project/seeed-python-reterminal/