Tool to track homeassistant dependencies #221

Open
opened 4 months ago by zentoo · 3 comments
zentoo commented 4 months ago

Hello !

I want to present you a little tool that I've wrote to help me to track homeassistant dependencies. I think it could help you a lot.

find_ha_deps.sh

#!/bin/bash
#
# find_ha_deps.sh:
#
# Locate origin of homeassistant dependency
# take one parameter:
# - "name of python package"
# - "deps" to locate origin of all local homeassistant dependencies
#
# zentoo 2020-2021 (b4b1@free.fr)


SYSTEM="/usr/lib/python*/site-packages"
LOCAL="/etc/homeassistant/deps/lib/python*/site-packages"
CUSTOM="/etc/homeassistant/custom_components"
CHECK_PATH="$SYSTEM $LOCAL $CUSTOM"

if [ -z "$1" ]; then
  echo "$(basename $0)"' need a "pkg name" or "deps" as parameter"'
elif [ "$1" = "deps" ]; then
  cd $LOCAL
  pkgs="$(ls -1d *.dist-info | sed 's|-[0-9.]*.dist-info||g')"
else
  pkgs="$@"
fi

for pkg in $pkgs ; do
  echo
  echo "===== $pkg ====="
  for path in $CHECK_PATH ; do
    cd "$path"
    results="$(grep --color=always --exclude-dir $pkg -HrnIiE "from $pkg|import $pkg")"
    if [ "$?" = 0 ]; then
      echo "[ $path ]"
      echo "$results"
    fi
  done
done
Hello ! I want to present you a little tool that I've wrote to help me to track homeassistant dependencies. I think it could help you a lot. **find_ha_deps.sh** ``` #!/bin/bash # # find_ha_deps.sh: # # Locate origin of homeassistant dependency # take one parameter: # - "name of python package" # - "deps" to locate origin of all local homeassistant dependencies # # zentoo 2020-2021 (b4b1@free.fr) SYSTEM="/usr/lib/python*/site-packages" LOCAL="/etc/homeassistant/deps/lib/python*/site-packages" CUSTOM="/etc/homeassistant/custom_components" CHECK_PATH="$SYSTEM $LOCAL $CUSTOM" if [ -z "$1" ]; then echo "$(basename $0)"' need a "pkg name" or "deps" as parameter"' elif [ "$1" = "deps" ]; then cd $LOCAL pkgs="$(ls -1d *.dist-info | sed 's|-[0-9.]*.dist-info||g')" else pkgs="$@" fi for pkg in $pkgs ; do echo echo "===== $pkg =====" for path in $CHECK_PATH ; do cd "$path" results="$(grep --color=always --exclude-dir $pkg -HrnIiE "from $pkg|import $pkg")" if [ "$?" = 0 ]; then echo "[ $path ]" echo "$results" fi done done ```
Poster

I can't upload .sh file so I've zipped it.

I can't upload .sh file so I've zipped it.
Owner

Thanks, willl play a little. Just gave you read permission to https://git.edevau.net/onkelbeh/ha-tools.

I use har.py to generate the main Ebuilds from a database. It reads all deps from the current homeassistant (from intall directory), except build deps (currently still in one of the templates).

The other files are (old) experiments.

MariaDB [repository]> desc integrations;
+--------------+-------------------+------+-----+---------+-------------------------------+
| Field        | Type              | Null | Key | Default | Extra                         |
+--------------+-------------------+------+-----+---------+-------------------------------+
| domain       | varchar(32)       | NO   | PRI | NULL    |                               |
| useflag      | varchar(32)       | YES  | UNI | NULL    |                               |
| name         | varchar(64)       | YES  |     | NULL    |                               |
| P39          | enum('Y','N','-') | YES  |     | NULL    |                               |
| isuse        | enum('Y','N')     | YES  |     | NULL    |                               |
| isuse_min    | enum('Y','N')     | YES  |     | N       |                               |
| isuse_full   | enum('Y','N')     | YES  |     | N       |                               |
| suggest      | enum('','+','-')  | NO   |     |         |                               |
| canonical    | varchar(128)      | YES  |     | NULL    |                               |
| requirements | varchar(220)      | YES  |     | NULL    |                               |
| usetext      | varchar(80)       | YES  |     | NULL    |                               |
| introduced   | varchar(10)       | YES  |     | NULL    |                               |
| last_update  | timestamp         | YES  |     | NULL    | on update current_timestamp() |
+--------------+-------------------+------+-----+---------+-------------------------------+
13 rows in set (0.001 sec)

MariaDB [repository]> desc package_subst;
+----------+-------------+------+-----+---------+-------+
| Field    | Type        | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| pypiname | varchar(32) | NO   | PRI | NULL    |       |
| pkgname  | varchar(32) | NO   |     | NULL    |       |
+----------+-------------+------+-----+---------+-------+
2 rows in set (0.001 sec)
Thanks, willl play a little. Just gave you read permission to https://git.edevau.net/onkelbeh/ha-tools. I use har.py to generate the main Ebuilds from a database. It reads all deps from the current homeassistant (from intall directory), except build deps (currently still in one of the templates). The other files are (old) experiments. ``` MariaDB [repository]> desc integrations; +--------------+-------------------+------+-----+---------+-------------------------------+ | Field | Type | Null | Key | Default | Extra | +--------------+-------------------+------+-----+---------+-------------------------------+ | domain | varchar(32) | NO | PRI | NULL | | | useflag | varchar(32) | YES | UNI | NULL | | | name | varchar(64) | YES | | NULL | | | P39 | enum('Y','N','-') | YES | | NULL | | | isuse | enum('Y','N') | YES | | NULL | | | isuse_min | enum('Y','N') | YES | | N | | | isuse_full | enum('Y','N') | YES | | N | | | suggest | enum('','+','-') | NO | | | | | canonical | varchar(128) | YES | | NULL | | | requirements | varchar(220) | YES | | NULL | | | usetext | varchar(80) | YES | | NULL | | | introduced | varchar(10) | YES | | NULL | | | last_update | timestamp | YES | | NULL | on update current_timestamp() | +--------------+-------------------+------+-----+---------+-------------------------------+ 13 rows in set (0.001 sec) MariaDB [repository]> desc package_subst; +----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------+-------+ | pypiname | varchar(32) | NO | PRI | NULL | | | pkgname | varchar(32) | NO | | NULL | | +----------+-------------+------+-----+---------+-------+ 2 rows in set (0.001 sec) ```
Poster

I understand better how you can create so many ebuilds relateed to so many dependencies.

My tiny tool is more an "after install" tool to print dependencies that have been installed locally by home assistant at running time.
So good to catch inconsistencies.

I understand better how you can create so many ebuilds relateed to so many dependencies. My tiny tool is more an "after install" tool to print dependencies that have been installed locally by home assistant at running time. So good to catch inconsistencies.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.