Remote file renaming/moving
Hi, I have a requirement to push a file to SFTP server. But since the file is quite large and to avoid race condition (we writing and remote function reading at the same time) we like to write the file with different extension or to a temp folder in remote server and them rename or move the file at the server. None for the File snaps support these feature. Could you please help me identify a way around to address above problem.7.4KViews1like13CommentsPython script: Move
Hello, I’m new to using Snaplogic and have gotten struck trying to integrate my python script into the script snap. Purpose: Use python script in Script snap to move files and update the name with a timestamp. Pipeline variables: fsrc, fdst, fname. For my example I’m just trying to move a text file called: Test1.txt that is sitting at: sldb:///projects/Cory Sharpe to:sldb:///projects/Shared. While this can be done with a copy+delete snap, I’m looking to do this using a script. Thanks! Code: #Pseudo-code: #Get: File Name, Source, and Destination pipeline variables #Move: File name to Destination + append timestamp to File name from com.snaplogic.scripting.language import ScriptHook import os import time fsource = $_fsrc fdest = $_fdst fname= $_fname #Dont think lists will work here halved= timeval=(time.strftime(“_%Y%m%d%H%M”)) class FTS(ScriptHook): def init(self, input, output, error, log): self.input = input self.output = output self.error = error self.log = log def execute(self): try: Result=FileCheck() if Result: print(fname) SnapMove(fname) else: print(“Result == “,Result,”. Ending.”) except Exception as e: errWrapper = { ‘errMsg’ : str(e.args) } def SnapMove(fname): try: halved=fname.split(‘.’) NewName=(halved[0]+timeval+“.”+halved[1]) fname = os.path.join(fsource, fname) NewName = os.path.join(fdest, NewName) os.rename(fname, NewName) except Exception as e: errWrapper = { ‘errMsg’ : str(e.args) } def FileCheck(): if os.path.exists(fdest)==False: os.makedirs(fdest) if os.path.exists(fsource)==False: print(fsource, “does not exists.”) return False if os.path.isdir(fsource)==False: return False if os.path.exists(fsource+“/”+fname)==False: return False hook = FTS(input, output, error, log) **note that tabs were lost on post.5.5KViews0likes4CommentsScript Snap user interface challenges
In using the Script snap to invoke a script for transformation, I find the UI behavior relating to the Script file input box and Edit script button. Let me describe what I did and what I find confusing. I started out testing a script that I entered using the Edit Script button. At some point, I opted to use an IDE to edit the script so I uploaded the script file to my project and used the Script file input box to specify the file name. If I click on the Edit Script button now, I see the old version of my script instead of the contents of the uploaded script file. I deleted the contents from the Edit Script window and saved. If I press Edit Script again, it generates the base script template. It seems like the Script file and Edit Script button are meant to be mutually exclusive. Why doesn’t the UI disable the Edit Script button after I point to a script file?2.1KViews0likes1Comment