Scripting question

How would I go about doing file IO in a project library script?

import os
print(os.getcwd())
with open(os.getcwd() + "\\testfile.txt", "w+") as file:
file.write("test")

This doesn’t work, it gives me errno13, so does trying to directly write to my desktop

Why do you ask this specifically? (The project library has no scope–functions there run in the caller’s scope.)

I suspect you’ve lost track of what JVM is running your code.

FWIW, for best results, use java’s I/O libraries, not jython’s.

2 Likes

Perspective scope/gateway scope, mostly just out of curiosity as I familiarize myself with scripting. In particular I was trying this from the script console, and I also tried just purely running the relevant code in that script console

A Perspective script is not going to be able access your desktop unless

  1. You’re running your session on your gateway, and
  2. You’ve made security changes to allow the gateway service to access your files, and
  3. The path in your script is absolute

The designer script console is Vision scope. I’m very sure you’ve heard this before. :frowning:

1 Like

Ah, yep, that’d do it, thanks!