Plugin help

Posted on
Mon Jan 08, 2024 2:45 pm
mwoodage offline
User avatar
Posts: 174
Joined: Dec 19, 2014
Location: Devon UK

Re: Plugin help

Hi all,
I've now hard coded the username and password into the script and have it running from a schedule to update every hour. So it's working, which is good news,

Neil, I tried putting the full path to the credentials file into the script, but couldn't get this to work. I also tried moving the script (and the path) to other locations, tried saving the file in different formats and re-writing it completely as a new file, nothing worked! It was the same error every time.

Ryan, thank you for your help - i'd rather not hard code the information, but at the moment this is the only option - i'm assuming the information is safe as it's only contained on my system? Is there another way we can do the same thing but seeing the information safe?

It does seam odd that the credentials file is not accessible when running it from Indigo, but the same file works when run from terminal. Is this just an Indigo quirk?

Thanks All
Martin

Posted on
Mon Jan 08, 2024 2:49 pm
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Plugin help

mwoodage wrote:

It does seam odd that the credentials file is not accessible when running it from Indigo, but the same file works when run from terminal. Is this just an Indigo quirk?



It's either a search path issue, or a user permission issue. Neither is specific to Indigo per se, but are because you're running the script from two different environments.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Jan 08, 2024 2:55 pm
mwoodage offline
User avatar
Posts: 174
Joined: Dec 19, 2014
Location: Devon UK

Re: Plugin help

Thanks Joe,
I've tried the credentials file in different locations, changing the full path in the script each time and checked the permissions each time - giving it full read/write access.
I've also moved the whole folder to different locations, and running it from terminal, which works, and from indigo which doesn't.

Anyhow, it's working for now, which is fantastic - if there's a safer way of hosting the username and password then it would be good to try that,

Thanks
M

Posted on
Mon Jan 08, 2024 3:03 pm
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Plugin help

It's all limited to that one machine, so if you get a breach of that machine, you have much bigger issues to worry about.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Jan 08, 2024 3:14 pm
neilk offline
Posts: 715
Joined: Jul 13, 2015
Location: Reading, UK

Re: Plugin help

Martin - as Joe says your credentials for other plugins and the credentials.json file is just as vulnerable as having them in this script (they are all stored in text files). The real advantage of having them external is if you share the script (on here for example) you need to be careful to redact it, whereas if the credentials are stored in a separate file you don't have that risk. (I did something similar uploading my early plugin code to GitHub that had details in I did not intend to share).

Keeping the machine secure with a strong unique passwords and you should be fine.

With the script running this way, you don't need to use the API to update the variables, you could do it directly in Python and also add updates to the indigo log if it fails/succeeds etc. Not necessary as this will work, but a good learning exercise.

Neil

Posted on
Mon Jan 08, 2024 4:25 pm
mwoodage offline
User avatar
Posts: 174
Joined: Dec 19, 2014
Location: Devon UK

Re: Plugin help

Thanks Neil, Joe,
I really appreciate the explanation and info, the machine is fairly well locked down with secure passwords so hopefully we’ll be ok

Thanks
Martin


Sent from my iPhone using Tapatalk

Posted on
Mon Jan 08, 2024 5:01 pm
jay (support) offline
Site Admin
User avatar
Posts: 18224
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Plugin help

A couple of final thoughts:

1) As much as possible, you want to use full paths when dealing with files and shell commands because the environment that the host process uses. You could get the Indigo installation folder and then construct the full path from that, which would probably have worked.
2) I never said it wouldn't work because of its use of asyncio, I said it may not work, particularly if run embedded. Embedded scripts (and linked scripts to a lesser extent) run in a special host environment and use a special way of loading. I don't believe anyone has actually tested a script that uses asyncio when running from that specific environment, therefore I wasn't sure if it would work or not.

In any event, I'm glad you found a solution. Might make for an interesting plugin if someone wanted to give it a try.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Jan 12, 2024 9:52 am
mwoodage offline
User avatar
Posts: 174
Joined: Dec 19, 2014
Location: Devon UK

Re: Plugin help

I'm feeling quite pleased with myself!!

So, this week i've been monitoring the Indigo Schedule I set up to run the indigo_variables.py script with my username and password imbedded in it. You'll remember last week we couldn't get the info from the credentials.json file to work That method has not been working that well - 9 times out of 10 it just gives an error.

So, today after a bit of Googling I stumbled across the idea of getting Indigo to run a seperate script that runs the indigo_variables.py script, and it works!

I now have the following running from a separate folder outside of Indigo, that gets executed by an Indigo Schedule every hour.

Code: Select all
import os

def execute_python_file(file_path):
    try:
        os.system(f'python3 "{file_path}"')
    except FileNotFoundError:
        print(f"Error: The file '{file_path}' does not exist.")

file_path = "/Library/Application Support/Perceptive Automation/Python3-includes/indigo_variables.py"
execute_python_file(file_path)


This way Indigo quite happily runs the indigo_variables.py script.

Maybe I am a Python coding genius after all :lol: :lol: :lol: :lol:

Who is online

Users browsing this forum: No registered users and 14 guests