-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run TI Process After SFTP Transfer Complete #119
Comments
Hi @eCapitalAdvisors , I have never used this library myself, but for sftp you could perhaps look into pysftp. Regarding the TI process execution afterwards. This would be fairly simple: # copy files through sftp
process_name = "Bedrock.Server.Wait"
with TM1Service(**config['tm1srv01']) as tm1:
success, state, error_log_file = tm1.processes.execute_with_return(
process_name=process_name,
pWaitSec="1") |
Marius, import paramiko
import configparser
config = configparser.ConfigParser()
config.read(r'C:\Users\tgaluska\config.ini')
from TM1py import TM1Service
class SSHConnection(object):
def __init__(self, host, username, password, port=22):
self.sftp = None
self.sftp_open = False
self.transport = paramiko.Transport((host, port))
self.transport.connect(username="test.user", password="test1234")
def _openSFTPConnection(self):
if not self.sftp_open:
self.sftp = paramiko.SFTPClient.from_transport(self.transport)
self.sftp_open = True
def get(self, remote_path, local_path=None):
self._openSFTPConnection()
self.sftp.get(remote_path, local_path)
def put(self, local_path, remote_path=None):
self._openSFTPConnection()
self.sftp.put(local_path, remote_path)
def close(self):
if self.sftp_open:
self.sftp.close()
self.sftp_open = False
self.transport.close()
if __name__ == "__main__":
host = "adaptive1.ecap.local"
username = "test.user"
pw = "test1234"
origin = 'E:\Adaptive\Channels.csv'
dst = 'C:\Tm1_Models\Blank\sourcefiles\Channels.csv'
ssh = SSHConnection(host, username, pw)
ssh.get(origin, dst)
with TM1Service(**config['Blank']) as tm1_target:
tm1_target.processes.execute('CreateChannels')
ssh.close() |
Hi, thanks for the code. This is a common use case I think. generally it's good if your wrap your code like this: print('Hello World') Strange... I have copied code samples from my IDE (pycharm) before and the indentation was not removed. Actually the best way to share it though would be to fork the tm1py-samples repository and create a Merge Request that includes your changes. |
Marius,
Sorry to post this here if it should be somewhere else. Have you ever initiated a TI Process after an SFTP transfer completed. I am running a python script on Server #1 to transfer a csv file to Server #2 and after it completes I want a TI process to run. Do you have anything like this I couldnt find anything even though I search the tm1py area.
Thanks
The text was updated successfully, but these errors were encountered: