Skip to content

Commit

Permalink
se/msg: Be a little bit more carefull with the hardcoded path
Browse files Browse the repository at this point in the history
The path replacement function tries to remove `/se` from the full path.
However, if the path already contains `/se`, such as for example in
`/solaredge/semonitor/se/msg.py` the path gets completely messed up.

Instead, by using python's `removesuffix`, we get what we wanted.

Signed-off-by: Olliver Schinagl <[email protected]>
  • Loading branch information
oliv3r committed Jun 21, 2023
1 parent 8555586 commit 21760fe
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion se/msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
sleepInterval = .1

# Hard coded last0503.msg file. os module used to find full path to calling msg.py file, then removes the se part so it's essentially the root of solaredge (where semonitor.py lives)
LAST0503FILE = os.path.dirname(os.path.realpath(__file__)).replace('/'+ __name__.split(".")[0], '') + "/last0503.msg"
LAST0503FILE = os.path.dirname(os.path.realpath(__file__)).removesuffix(__name__.split(".")[0]) + "last0503.msg"

class SECrypto:
def __init__(self, key, msg0503):
Expand Down

0 comments on commit 21760fe

Please sign in to comment.