Jump to content

Installation script won't run


sully8391

Recommended Posts

Hi All,

 

I'm trying to implement a simple installation script that will copy a resource file into the user libraries folder. I tested it outside of Vectorworks and it successfully copied and pasted the file into the proper folder, but when I try to pair it with installation nothing happens. It actually appears that script isn't running at all. I altered it so it would throw an error, and nothing happened, then I tried to use it to create some text, and still nothing. It's sitting at the same directory level as the folder holding all of the plugins, which appears to be correct according to this page: https://developer.vectorworks.net/index.php/VS:Implementing_Installation_Script

 

Anyone know what I might be missing?

Link to comment

The script must be named install.py

 

The script must be at the root level of the zip folder. If it is inside an enclosing folder, it will not run. 
 

This could present an issue if a user unzips the install package and then tries to re-zip. In 2018 SP1 and up, you can work around this by changing the zip extension to .vwlibrary

Link to comment

I see, I totally just compressed it wrong. It's running now, but I'm having loads of trouble getting to the directory that the actual file is in. I've tried os.getcwd() and os.path.dirname(sys.argv[0]), but both of those return the directory of the process (different from when I run the script standalone). I need a way to locate the resource file no matter where a user saves the downloaded zip. I might have more luck programming at a more reasonable hour, but if you know a magic line of code that achieves this, I'd love to hear it.

Link to comment

So from my understanding the when you install the ZIP file it copies all the contents of the Zip FIle into the Users Plug in folder,  so could you not package the Rource file within the .Zip then use vs.GetFolderPath() to get the users plug in folder, aswell as Library Folder and use shutil.move to move them from plugins folder to required folder.

 

import shutil
import os
import vs

def manualPackageInstall(foldername):
    shutil.move(os.path.join(vs.GetFolderPath(-2) , foldername ),  # Path to Folder to move in plugin Folder
                os.path.join(vs.GetFolderPath(-13) , foldername))  # Path to Libraries in User Folder

Something like that?

Link to comment
10 hours ago, sully8391 said:

I see, I totally just compressed it wrong. It's running now, but I'm having loads of trouble getting to the directory that the actual file is in. I've tried os.getcwd() and os.path.dirname(sys.argv[0]), but both of those return the directory of the process (different from when I run the script standalone). I need a way to locate the resource file no matter where a user saves the downloaded zip. I might have more luck programming at a more reasonable hour, but if you know a magic line of code that achieves this, I'd love to hear it.

 

outputFolder is the magic variable that holds the path to the installed location. This is usually the user plug-ins folder, though using this variable would catch installing into a workgroup folder.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...