[Dynamic Package] Directory Check

More
1 year 9 months ago - 1 year 9 months ago #24352 by prashant
Hi,

IN context to what calculated value means 

I have a simple script , it checks if c:\tmp exist , if not create it , it works as a package script , but gives error when I run this directory check calculated value 

import os
import etltools

try:
    folder_path = r'C:\tmp'
    if not os.path.exists(folder_path):
        os.makedirs(folder_path)
    Result.Value = 1
except Exception as e:
    etltools.SetVariable('error_message', str(e))
    Result.Value = 0

 
Last edit: 1 year 9 months ago by prashant.
The following user(s) said Thank You: admin

Please Log in or Create an account to join the conversation.

More
1 year 9 months ago #24356 by admin
In case of directory check you script must return as string value which represent a "Directory path" you want to check 

Mike
ETL Architect

Please Log in or Create an account to join the conversation.

More
1 year 9 months ago #24360 by prashant
OK, makes sense, 

Below worked

import os
import etltools

try:
    folder_path = r'C:\tmp'
    if not os.path.exists(folder_path):
        os.makedirs(folder_path)
    # Return folder path if successful
    Result.Value = folder_path
except Exception as e:
    # Return error message if an exception occurs
    etltools.SetVariable('error_message', str(e))
    Result.Value = "Error"
 

Please Log in or Create an account to join the conversation.

More
1 year 9 months ago #24361 by prashant

In case of directory check you script must return as string value which represent a "Directory path" you want to check 
Can this be assumed for all calculated values? A string must be returned ?

Please Log in or Create an account to join the conversation.

More
1 year 9 months ago - 1 year 9 months ago #24364 by admin
1 Your script is wrong,
There is no need to check if directory exists inside the script.
AETL does it for you.

The execution sequence is:
  1. All parameters are calculated/assigned
  2. Action is executed
  3. Depending on execution result next action is executed.

Calculated parameters give a lot a lot of flexibility but they must be used with caution   

2 Can this be assumed for all calculated values? A string must be returned.
  
This is correct and depending on the parameter type they must be properly formatted
  

Mike
ETL Architect
Last edit: 1 year 9 months ago by admin.

Please Log in or Create an account to join the conversation.

Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Read more
Marketing
Set of techniques which have for object the commercial strategy and in particular the market study.
Google
Accept
Decline
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Google Analytics
Accept
Decline
Functional
Tools used to give you more features when navigating on the website, this can include social sharing.
Advertisement
If you accept, the ads on the page will be adapted to your preferences.
Google Ad
Accept
Decline
Save