Access a network drive

Ignition runs as a service, so it can’t access mapped drives on the host computer. Instead, you map it inside Ignition to allow for access. You don’t need D: to be mapped on the host, you just do the config file addition then stop and start Ignition. It should then be mapped and accessible from Ignition as D:\sampleImage.png

1 Like

So this is what I want to do:

There is a folder in my network drive with some pictures in it. I would like to be able to access that folder and get the picture names and put it on a list

I did not configure anything in my D drive and I did not create any folders on my D drive.

How is this going to be possible?

wrapper.share.1.location="\\fileserver4\Automation\"
wrapper.share.1.target=I:
wrapper.share.1.type=DISK
    import os
	input_path = "I:\"
	fileList = os.listdir(input_path)
	self.getSibling("TextArea").props.text=fileList
1 Like

I get the same error:

org.python.core.PyException
java.lang.IllegalArgumentException: Cannot create PyString with non-byte value

java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Cannot create PyString with non-byte value

	caused by IllegalArgumentException: Cannot create PyString with non-byte value

What line does it say the error is coming from?

Go to the script console and run this:

    import os
	input_path = "I:\"
	fileList = os.listdir(input_path)
    print fileList
1 Like

it says 'input_path" is not defined.
should this be
input_path = "I:\"
or

input_path = "I:\full path"

?

I have tried with both

Sorry, forgot, need two backslashes after drive letter

"I:\\"
1 Like

This gives me the content of the I folder, not that specific folder I want and when I write the full path one time I get this error:

Traceback (most recent call last):
  File "<input>", line 2, in <module>
TypeError: coercing to Unicode: need string, list type found

and another time I get the list of what has been in “I” folder!!! It is very strange!

So I get two different results for the same script and none of them is what I am expecting to get.

Don’t just use I:\\ This only represents \\fileserver4\Automation\ from what I can tell. If you need to drill down into another folder in I:\\ then you need to include that in the path.

I:\\fullPath

Show me your full path assigned to input_path

1 Like

In python strings, as in most programming languages, backslashes are special. To use them in your paths, you need to double all your backslashes.

3 Likes

Thank you!!! I was able to get the file names in the console, now I am using the exact same script on my button event handler which uses double backslash but I get an error. It is working in the console but not on the event handler

OSError: [Errno 20] Not a directory

This is my code and the folder that I was looking for was in the Y folder instead of I, I changed everything based on that.

image

import os
	input_path ="Y:\\MES Ignition\\Controls\\Design\\sample Image Folder\\Images\\20\\Pass_Barcode\\"
	fileList = os.listdir(input_path)
	self.getSibling("TextArea").props.text=fileList

And in my wrapper I am using:

wrapper.share.1.location="\\fileserver4\Automation\"
wrapper.share.1.target=Y:
wrapper.share.1.type=DISK


wrapper.ntservice.account=user   #my own username
wrapper.ntservice.password=pass   #my own pass
wrapper.share.1.account=domain\user   #my own domain\user
wrapper.share.1.password=pass   #my own pass

It maybe a scope issue. I think clients will use the file system of the client computer and not the gateway computer so it is looking for a Y drive on the client not the gateway. You would need to call it from a gateway script I believe.

1 Like

Hi, I also have the same problem with network drive. Even after changing the config file and checking using the script console, my Gateway script still can not access network drive. Could you fix your problem after that? Many thanks.

That isn't a valid check. The script console runs in Designer scope, not gateway scope. Opening a desktop session on the gateway to run the designer is not the same environment as a service.

Did you restart the gateway after changing the config file? And then check in your wrapper log to look for errors mapping the drive? (The wrapper log is a text file--it has information that does not show up in the gateway's logs via the web interface.)

Hi Phil, thank you for your reply! I added the network drive and account credentials. However after checking the wrapper log file, somehow my correct input password is cut short during the stop and start process. As a result, the error is wrong network password. Do you know why? Thanks in advance.