Jump to content
Ketarin forum

Execution order of an application's commands


Anonymous
 Share

Recommended Posts

I have written some code to use an application's "Execute the following command before downloading" to assign values to local variables.  When testing the code, I realized that the variables in an application profile are getting resolved before this code is executed.  In the case of my implementation, I have set up other variables that rely on pre-download information to resolve urls correctly.

 

"Technically" this command does what it says, as the code in this section will run before an application is downloaded.  However, I believe changing the order opens up more functionality to someone who's using these commands.

 

If the order of execution is not critical, please consider changing this order or giving the option to change it per profile.

Link to comment
Share on other sites

  • 2 weeks later...

can you share with us the specifics of your pre- and post-commands and what you're expecting to happen?

 

variables are resolved before pre-DOWNLOAD commands operate because they're required in order to facilitate various behaviour, such as version comparison.

 

if you want to shim in a different download engine (such as aria2c (for bittorrent) or wget) you can build the commands within pre-download and exit with a return value of 3 in order to avoid Ketarin's default download behavior.

Link to comment
Share on other sites

I get that, but what happens when Ketarin can't access the relevant triggers (e.g. hash data, etc.) because it can't resolve a directory or URL due to "old" data?

 

The first time I encountered this execution order problem was because of the "download location" field.

 

Every application profile I have is built off a template that shares the same basic download location:

\\server\software\{company}\{app_name}\archive\{version}\{platform}\{ps_appdeploy}{app_name:replace: :_}_installer.{url:ext}

 

For Microsoft OneDrive, it resolves to:

\\server\software\Microsoft\OneDrive\archive\17.3.6760.0105\macOS\OneDrive_installer.pkg

 

This generic download location is software depot for an IT department and some installers have a deployment script wrapped around it.  When this occurs, it requires the downloaded file to live in a nested folder.  In order for Ketarin to place the download in the correct folder, a normally blank variable is assigned a value of "Files\" to adjust the location.

 

So another piece of software, like SONY Catalyst Browse is resolved to:

\\server\software\SONY\Catalyst Browse\archive\2016.3\win_x64\Files\Catalyst_Browse_installer.exe

 

Who the heck wants to manually keep track of a variable that determines it's download location from a template on hundreds of application profiles?  I don't, so I wrote a script to detect the "Files\" folder and dynamically adjust the download path before it's executed.

 

This is where the problem lies.  Ketarin's timing of "Execute the following command before downloading" occurs after its already resolved the download location it's going to use, despite those value changing "before downloading".

 

While this is not the scenario that led me to start this post, I think it's enough of an example to get the point across.

Link to comment
Share on other sites

While I understand where you're coming from, that's quite the fringe case. It would be better to build the correct path as a variable and use that variable within the download location field. Your example above, if i'm reading it correctly, could be resolved with a couple variables using just the "replace" function.

path1 = \\server\software\{company}\{app_name}\archive\{version}\{platform}\{ps_appdeploy}{app_name:replace: :_}_installer.{url:ext}

path2 = {path1:replace:\Files\:\}

 

This would preserve the existing functionality that allows variables to each be fully populated before "pre-download" which allows the pre-download script to have access to context that might be necessary. For example, I personally use Aria2 for several torrent-based downloads (tails and stuff like that) which aren't available via other means. The ability to flesh out the download location allows me to use a generic template to purge the previous tails download even though it's not a consistent name -- before I trigger the new torrent file download that then passes to the post-download and actually selects the individual files to download via aria2. 

Link to comment
Share on other sites

Using replace doesn't help.  The example I provided is spitting out the contents of app variables in the download location and "Files\" isn't something that can be derived by Ketarin itself, hence the need to do it in a script before downloading.

 

Irrespective of that, I'm not looking to solve the example I provided.  It was only meant to give context.

 

Another, less verbose, non-fringe example (and the reason I posted to being with) is with working with password protected websites.  Since Ketarin does not currently have the ability to read cookies, some sites are impossible to load into Ketarin.  I got around that by grabbing the necessary values to authenticate using a pre-download script which writes the values into variables in the app profile.  Because the execution order of "Execute the following command before downloading", these values are not updated when Ketarin attempts to visit the download URL and it errors with a 404.  I rerun the app profile again and it downloads just fine because those variables are now valid at the time of execution.

Link to comment
Share on other sites

it sounds like what you really want then isn't an execution order change, but the ability to use a script as part of a variable assignment. that's a fantastic idea and doesn't change the execution order for those of use that depend on variables being fully populated in the pre-download script.

 

i see the best way to implement this as an alternative to 'content from URL (start/end)', 'content from URL (regex)', 'textual content' in a variable assignment. like the regex selections, you'd then select the specifics - language of choice, variable return method (either return/exit code or value of x at end of script), and it would probably require some changes or at least exposure to the variable assignment order. currently i *believe* that the variables are calculated in order in the variable list unless they depend on another variable and that variable is then processed prior -- but there's no exposure to that process as far as i can see. this new variable scripting option would require that mechanism to be exposed and would also probably require the ability to reorder variables so you can ensure you have proper scripting context to dependent variable values. the execution order should be automatically imposed based on dependency and maybe a visual indicator for logic loops and similar problems, with the ability to reorder those variables that have similar staging order for dependence but ultimately depend on something else that might alter their proper execution order.

 

if that's what you're really after, we should get it up as a feature request and poll Florian for input.

Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.