How to Export a Certificate using the Certificate Export Wizard (Windows only)
How to Export a Certificate using the Certificate Export Wizard In Sisense version 7.2 and later, SSL (Secure Sockets Layer) settings have moved from Microsoft IIS into the Sisense Configuration Manager. For organizations moving to Sisense 7.2 and above from an earlier version that would like to continue using SSL, it is necessary to obtain the certificate to make SSL work. See the steps below to attempt to obtain the certificate from the server's certificate store if your organization previously had SSL set up on the Sisense web server. Organizations can also opt to contact their Certificate Authority (CA) to obtain an up-to-date copy of your site's .pfx or .crt and .key files. This explanation utilizes mmc (Microsoft Management Console) to export the certificate. On your webserver, search programs for mmc and select mmc.exe In the window that appears, click on "Add/Remove Snap-in..." In the "Available snap-ins" column, click on Certificates then click "Add >" to add it to the "Selected snap-ins" column In the resulting pop-up, select "Computer account" then click 'Next' Leave the settings as is on the next screen and click Finish Click on OK to add the Certificate snap-in On the left-hand side of the screen, expand Certificate (Local Computer) > Personal > Certificates Right-click on your certificate, go to All Tasks > Export The Certificate Export Wizard will appear which will assist you in exporting your organization's certificate to the appropriate format. Select the Next button. On the Export Private Key screen, select "Yes, export the private key". The private key is necessary for SSL to work in Sisense 7.2 and higher. Then select the Next button. On the Export File Format screen, select the Personal Information Exchange (.PFX) file option and hit the check boxes that correspond to the options below, then select the Next button. ☐ Include all certificates in the certification path if possible ☐ Export all extended properties ☐ Enable certificate privacy On the Security screen, select the Password checkbox and enter a password. Make sure the encryption setting is TripleDES-SHA1. Then select the Next button. Select the file location in which to save the exported certificate. Then select the Next Button. On the last screen select the Finish button to complete the setup. Complete the setup in this guide to set up SSL in Sisense.8.6KViews0likes0CommentsAutomatically Backup Sisense Web Data
Sisense uses MongoDB for storing your Sisense web environment information. This information includes how dashboard and widgets are configured, your system's users and groups, and many other configurations. Since the web environment can regularly change, and may need to be restored, it's useful to keep regular backups of this data. This article shows how to use a program that will perform daily backups of this data: **This article is only relevant Sisense Windows versions 6.7 and above. For Sisense Linux versions, please see Backing Up and Restoring Sisense Download the attached .bat files The MongoBackup.bat file is used for backing up your MongoDB, and the MongoRestore.bat file is used in case you need to restore the backed up information. You can find both of these files here: MongoBackup.bat MongoRestore.bat Create a WriteUser In order to be able to use these scripts, you need to have a WriteUser to your MongoDB. For more information on how to do so, check out our documentation. Change the credentials You can open each of these files in notepad. It will look like this: Change the credentials to those you've just created. Schedule the script The only script you should schedule is the MongoBackup.bat, Since you'll only use MongoRestore.bat in case you need to restore your data. The easiest way to do so is to use the Windows program Task Scheduler. Information on how to schedule a task can be found here: https://support.microsoft.com/en-us/office/create-edit-delete-and-restore-tasks-30346281-30d4-4d6b-a6fa-55beca8d38a31.3KViews0likes0CommentsCustom Domain For Managed Services - Re-Branding the URL
In some cases, a customer would like to have his own domain instead of the *.sisense.com provided by the Sisense team. If you wish to use your own domain please follow the steps below: Windows Generate a PFX file of your domain. Open a ticket including the requested domain and transfer the PFX file to the customer data FTPS folder including a txt file with a password. Sisense Agent will validate the PFX file. If the PFX file is valid, the Sisense Agent will reach out to schedule a time to switch the domain. At the time of the switch, you will need to add an Aname record on your domain controller pointing the new domain name to your designated Sisense machine IP. Changing the domain may take a few minutes to update so you may want to declare downtime during the process. Linux Sisense will request a free certificate via ACM (Amazon Certificate Management) service which generates a certificate on your approval via your DNS. Please read the documentation with details from Amazon if you need more details: https://docs.aws.amazon.com/acm/latest/userguide/dns-validation.html In this scenario, the Customer doesn't need to provide us with certificate files if they are an owner of a custom DNS. This certificate will be auto-prolonged if the CNAME records will be kept in DNS. Open a ticket including the requested domain and ask to move it to the Cloud Ops Team. The agent will schedule the time of the DNS change.1.4KViews0likes0CommentsRestart all Sisense Services Using PowerShell or Force Restart All Sisense Services
These instructions are for customers using Sisense On-Prem deployments. If you are a Sisense Cloud customer please reach out to Support for help with Services. Follow the instructions below to restart all Sisense services and IIS: Log on to the server with your administrator privileges. Locate PowerShell and run it as administrator (right click -> Run as administrator). Copy and run the following commands: Get-Service | where {($_.name -like "*sisense*" ) -or ($_.Name -like "*elastic*" )} | Restart-Service iisreset /noforce Follow the instructions below to Force Stop all Sisense Services and then Start them again: Log on to the server with your administrator privileges. Locate PowerShell and run it as administrator (right click -> Run as administrator). Copy and run the following commands: Get-Service | where {($_.name -like "*sisense*" )} | Stop-Service -Force Get-Service | where {($_.name -like "*sisense*" )} | Start-Service2.9KViews0likes0CommentsModifying Email Report URLs
Introduction When embedding Sisense in a parent application, there will be a need to route email reports to your parent application dashboard URL. For example, when a customer will load a dashboard in the embedded application, the dashboard URL might look something like this https://endcustomer.appowner.com/division/analytics?sisense_url=%2Fdashboards%2F{dashboard_oid} While the original Sisense dashboard URL might looks something like this: http://endcustomer-bi.appowner.com/app/main%23/dashboards/{dashboard_oid} In this case, when a customer receives an email report from the application, for instance to view a dashboard that was shared with them, they will be routed to the original Sisense dashboard URL and not the parent application URL. Solutions This article proposes two solutions to this: 1) Change the Alias field in the Admin/Settings of Sisense to the parent application URL. If the parent application dashboard URLs match this pattern: http://subdomain.domain.com/app/main%23/dashboards/{dashboard_oid} Then this solution will work. But, in case the parent application dashboard URL must be manipulated, you will need to apply the second solution. 2) Manipulate the embedded url token in Sisense templates. Let's use the dashboard share report as an example. If we open: path/to/email/templates/dashboard_report/html.ejs We will the see following: ... <td align="left" bgcolor="#ffffff"> <a name='dashboard' href='<%= url %>' target='_blank'> <img src='cid:<%= images[i] %>' id="<%= images[i] %>" name="<%= images[i] %>" /> </a> </td> We notice that the anchor tag has an EJS expression as the reference for the hyperlink: href='<%= url %>' The url token in this case evaluates to the original Sisense dashboard URL: url = http://endcustomer-bi.appowner.com/app/main%23/dashboards/{dashboard_oid} We can use JavaScript replace method to manipulate this token to match the parent application dashboard URL as so: <a name='dashboard' href='<%= url.replace('http://endcustomer-bi.appowner.com/app/main%23/dashboards/', 'https://endcustomer.appowner.com/division/analytics?sisense_url=%2Fdashboards%2F') %>' ... </a> When the email will be generated, the URL will resolve to the expected endpoint: https://endcustomer.appowner.com/division/analytics?sisense_url=%2Fdashboards%2F{dashboard_oid} and direct the customer to the dashboard in the parent application. * This solution was tested on Linux LA version 7.4.1.571 and Windows version 7.4.1.2KViews0likes0CommentsIdentifying Sisense Services
This article is a reference point for understanding Sisense services and what their purposes are. The notes column contains supplemental information about the service. Please note that this is not an exhaustive list of how you would interact with the services for each scenario. Current List of Sisense Services (as of Version 7.2) Service Name Name Purpose Notes Sisense.Broker Broker Responsible for communication between services. All micro-services utilize the Broker service. In High Availability deployments, this service is associated with RabbitMQ as well. Ensure this service is running as it is a prerequisite for other Sisense services to function. Sisense.CLRConnectorsContainer CLR Connectors Responsible for powering CLR (.NET) connectors. You may restart this service if you're having trouble with particular CLR-based connectors. Sisense.Collector Collector - Sisense Internal Monitoring Responsible for internal monitoring and collection of data about the machine and process performance. This service must be running in order to send logs for Sisense monitoring. Sisense.Configuration Configuration Manager Responsible for powering the Configuration Manager application located at http://localhost:3030 on your Sisense webserver. Also exposes APIs for other configurations. You may restart this service if you find you're having trouble getting the Configuration Manager site to load. Sisense.Discovery Discovery Responsible for saving and storing configuration changes including those made in the Configuration Manager. Typically you will leave this service alone outside of a Sisense migration. Sisense.ECMLogs ElastiCube Manager Logging Responsible for storing build logs from ECM 1.0 and ECM 2.0, PSM, APIS, etc. There should not be any reason for starting this service outside of basic configuration changes (Sisense migration, MongoDB changes, etc). Sisense.ECMS ECM 1.0 (Desktop ElastiCube Manager) Responsible for powering the Desktop ECM. You may restart this service if you're seeing issues building or accessing ElastiCubes on the desktop. Sisense.ECMServer ECM 2.0 (Web ElastiCube Manager) Responsible for powering the Web ECM. You may restart this service if you're seeing issues building or accessing ElastiCubes within Sisense Web. Sisense.Galaxy Galaxy Controls the majority of web server logic. At this time this service also controls: Emails Reporting Export to image You may choose to restart this service in the following example cases: Many API calls that failed with "api not found". User can log in but not able to navigate through dashboards upon login. Emails are not going out. Sisense.Gateway Gateway Main entry point of the Sisense system. This service routes the API between many of the microservices. By default, this services listens on port 8081 and can be changed within the Configuration Manager. You may restart this service if you are having trouble reaching the Sisense site on your designated port. Sisense.HouseKeeper HouseKeeper This service is responsible for memory management of the Sisense application. Typically there is not a need to restart or modify this service. Sisense.Identity Identity Responsible for Sisense groups, roles, users, etc. This service is responsible for authentication and user management. You may restart this service in instances where your user is unable to log in due to errors in authentication (not related to SSO authentication). Sisense.Jobs Jobs Responsible for triggering jobs including emails after a cube build, emailed reports on a schedule, etc. Typically there is not a need to restart or modify this service outside of troubleshooting scheduled jobs. Sisense.JVMConnectorsContainer JVM Connectors Responsible for powering JVM connectors. You may restart this service if you're having trouble with particular JVM-based connectors. Sisense.Orchestrator Orchestration Utilized in HA to synchronize and distribute built ElastiCubes on the build node to the query nodes. You may restart this service changing HA configuration settings. Please consult the HA documentation before restarting this service. Sisense.Oxygen Oxygen (Licensing) Responsible for communicating with Sisense to verify licensing You may need to restart this server if you are having licensing issues within the ECM or Sisense Web. Must be restarted upon license update (along with a logout and log back in). Sisense.Plugins Plugins Management Node.js service which builds plugins. Users do not need to restart this service each time they change plugins. Plugins service watches the plugins folder for changes and runs a build mechanism automatically. Sisense.QueryProxy Query Services Provides a unified way to translate and access the backend SQL Engines. Responsible for query executions, throttling, load balancing, versioning, streaming and results formatting. This service must be running in order for query execution to work. Sisense.Repository Repository Responsible for storing Sisense metadata including: Dashboards Users Data security This service maintains connection to the files contained in MongoDB This service must be running in order for users to view dashboards and log into Sisense Web. Sisense.Shipper Shipper Responsible for shipping logs to Sisense for monitoring. Reads data from C:\ProgramData\Sisense\Monitoring\LOGS folder and ships it. This service must be running in order to send logs for Sisense monitoring. Sisense.SPE Data Prep and Streaming Engine Responsible for powering: Export to Excel Preview table Data Wizard Custom tables and custom columns You should restart this service when changing configuration settings for any of the modules power by it. Sisense.StorageManager Storage Manager Responsible for storing files for file-based connectors such as CSV and Excel files Typically no need to restart or change this service. You should restart this service when changing configuration for this component such as changing the max file size or minimum hard disk space for uploading files.. Sisense.Usage Usage Service This service is responsible for saving off Sisense usage data. Typically no need to restart or change this service. You may restart this service after a change in configuration of the Usage feature. Notable services on Sisense Version 7.1 and below: Service Name Name Purpose Notes ElasticubeManagmentService ElastiCube Management Responsible for powering the Desktop ECM. This service was replaced by Sisense.ECMS and Sisense.ECMServer. You may restart this service if you're seeing issues building or accessing ElastiCubes on the desktop. Sisense.ECMLogsPersistenceService ECM Logs Responsible for storing build logs from the Desktop ECM. This service was replaced by Sisense.ECMLogs. There should not be any reason for starting this service outside of basic configuration changes (Sisense migration, MongoDB changes, etc). Sisense.Pulse Pulse Responsible for powering pulse alerts. This service was replaced by Sisense.Broker. You may restart this service if you are experiencing issues with Pulse across the board.3.9KViews0likes0CommentsHow To Set Up Outlook365 As The Email SMTP Server
Intended Audience If you'd like to replace the stock Sisense emailing service with an Outlook365 SMTP server, this guide is for you. Steps to set up: 1. Run POST v1.0 /settings/email_server With the following body: { "host":"smtp.office365.com", "pass":"", // SMTP SERVER ADMIN PASSWORD "greetingTimeout":0, "enable":true, "socketTimeout":0, "logger":false, "requireTLS":true, "debug":false, "connectionTimeout":0, "ignoreTLS":false, "port":587, "secure":false, "user":$SMTP_SERVER_ADMIN_EMAIL // YOUR SMTP SERVER ADMIN. i.e [email protected] } 2. Open the Configuration Manager by accessing localhost:3030 (Windows) or http://{IP}:30845/app/configuration/system on Linux. 3. Click 5 times on the Sisense logo (top left hand side) to open the advanced settings. 4. Click on the Base Configuration and find the Email section. 5. Change the email.senderEmail to match the user email set in step 1: 6. Restart the Galaxy and Gateway services for the changes to take effect. Note: You should be aware that Outlook365 has a limitation of a maximum of 3 concurrent connections. This means that no more than 3 email requests can be sent the server to the recipients. If more than 3 connections are made, the following reports will fail. If you notice that some emails haven't been received, modify step 1 parameters to enable the logger and debug logs: { ... "debug": true, "logger": true, ... } And restart the Gateway and Galaxy service. Then look for the following error: `432 4.3.2 STOREDRV.ClientSubmit; Sender Thread Limit Exceeded` in the Galaxy logs. Galaxy log location in Windows: %ProgramData%/Sisense/application-logs/galaxy Galaxy log location in Linux: /var/log/sisense/{namespace}/galaxy.log1.4KViews0likes0CommentsDisable Monitoring Logs From Being Sent To Monitoring Service
If for information security reasons you'd like to disable data sent to our monitoring tools, you may disable this by doing the following: On Sisense 7.0 and Above: To disable online logs and have ONLY offline logs, comment out the last paragraph in the shipper.conf file: C:\ProgramData\Sisense\Infra\Data\Shipper\Config\shipper.conf Then restart the Sisense.Shipper service. On Sisense 6.7 and Below: Within Windows Services, stop the monitoring service (after 6.7, the services are called Sisense.Shipper and Sisense.Collector. Before 6.7, there's only one service called Sisense.Monitoring). Using a text editor, open the file C:\Program Files\Sisense\Monitoring Agent\logstash\bin\infraAgent.exe.config Set the run_shipper_outer key to false: 4. Save the file. 5. Start services that were stopped in step 1.710Views0likes0CommentsDBfarm Cleaner, remove unattached cubes
When a build fails, the folder that was created up to that point with the data will still remain on your server. This can consume 100s of GB and required to clean from time to time. The attached application runs on the server cleaning all unnecessary folders. Steps for running the app - 1. Download the attached exe file 2. Run it as with the selected parameter elasticubedatacleaner <command> [options] Commands list List folders to delete without deletion. delete Delete unused folders. Options -h, --help Show help. --ecdatafolders [ECDATAFOLDERS] List of folders directory to scan. --ecservicename [ECSERVICENAME] Specify the name of the EC service. Default: Sisense.ECMS (for version 7.1 and earlier change the service to ElastiCubeManager --delete_alternative Delete Alternative folders. An alternative is created for a cube building in an accumulated mode in order to be used as a base cube once the second cube started799Views0likes0CommentsUploading Files Locally Using Rest (Linux)
In Sisense Linux distribution you are able to upload files to the Sisense environment via the file management Interface. This article describes few ways for uploading files programmatically using bash, Powershell and python. Powershell Script for uploading a file via rest api for Sisense version greater than L2021.5 # ------- Config ------- # Sisense base DNS # For example http://23.50.45.130:30845 $baseUrl="<Sisense DNS>" # Destination location on sisense server - must be accessible via Sisense file management interface $remoteLocation="/test1/data.csv" # Local file path $filePath="data.csv" # admin api token $apiToken="<Admin API Token>" # Should the new file override existing files with the same name $shouldOverride="true" # ------- End Of Config ------- # File Management URL $uploadPathUrl="/app/explore/api/resources/data" # Create URL to send file to $url=$baseUrl+$uploadPathUrl+$remoteLocation + "?override=" + $shouldOverride #Write-Output $url # Create authorization bearer header $authorization="Bearer $apiToken" #Write-Output $authorization # In order to add files via the file explorer, one requires also x-auth token. the next part fetchs x-auth using the admin api token $xauthpath="/app/explore/api/login" $xauthurl=$baseUrl+$xauthpath #Write-Output $xauthurl $headers = @{ 'Authorization' = $authorization } # Send request to get xauth # For https remove -AllowUnencryptedAuthentication $xauth = Invoke-RestMethod -Uri $xauthurl -Method Post -Headers $headers -AllowUnencryptedAuthentication #Write-Output $xauth $headers += @{ 'X-Auth' = $xauth } # Send a request to upload a file # For https remove -AllowUnencryptedAuthentication $res = Invoke-RestMethod -Uri $url -Method Post -Headers $headers -AllowUnencryptedAuthentication -ContentType 'text/csv' -InFile $filePath # Print response Write-Output $res Bash Script for uploading a file via rest api (using cUrl) for Sisense version greater than L2021.5 #!/bin/bash # ------- Config ------- # Sisense base DNS # For example http://23.50.45.130:30845 baseUrl="<Sisense DNS>" # Destination location on sisense server - must be accessible via droppy remoteLocation="/test1/data.csv" # Local file path filePath="data.csv" # admin api token apiToken="<Admin API Token>" # Should the new file override existing files with the same name shouldOverride="true" # ------- End Of Config ------- # File Management URL uploadPathUrl="/app/explore/api/resources/data" # Create URL to send file to url=$baseUrl$uploadPathUrl$remoteLocation"?override="$shouldOverride echo $url # Create authorization bearer header authorization="Bearer $apiToken" # In order to add files via the file explorer, one requires also x-auth token. the next part fetchs x-auth using the admin api token xauthpath="/app/explore/api/login" xauthurl=$baseUrl$xauthpath echo $xauthurl # Send request to get xauth xauth=$(curl -H "Authorization: $authorization" $xauthurl) echo $xauth # Send a request to upload a file res=$(curl -H "Authorization: $authorization" -H "X-Auth: $xauth" -H "Content-Type: text/csv" -d @$filePath $url) # Print response echo $res Power-Shell 1 file upload Example - Version <=L20121.3 The script below will allow the user to upload files programmatically, using REST command. The script itself is written in Powershell. Change the first 4 parameters dns - The URL you use for your Sisense site RemoteLocation - The location of the target file within File Manager FilePath - The local location of the file from the Local Server AUTH_TOEN - Generate a token and replace it with <token> $dns= 'https://myhost.sisense.com' $RemoteLocation= 'data/Test' $FilePath = 'C:\myfolder\myfile.csv'; $AUTH_TOKEN = 'Bearer <Token>' ############################################################### $pos = $FilePath.LastIndexOf("\") $URL = $dns+'/app/explore/!/upload?vId=0&rename=0&to=/'+$RemoteLocation; $filename = $FilePath.Substring($pos+1) $fileBytes = [System.IO.File]::ReadAllBytes($FilePath); $fileEnc = [System.Text.Encoding]::GetEncoding('UTF-8').GetString($fileBytes); $boundary = [System.Guid]::NewGuid().ToString(); $LF = "`r`n"; $Headers = @{'Authorization'=$AUTH_TOKEN}; $bodyLines = ( "--$boundary", "Content-Disposition: form-data; name=`"filename`"; filename=`"$filename`"", "Content-Type: application/octet-stream$LF", $fileEnc, "--$boundary--$LF" ) -join $LF Invoke-RestMethod -Uri $URL -Method Post -ContentType "multipart/form-data; boundary=`"$boundary`"" -headers $Headers -Body $bodyLines Python Example For Folder Syncing (Upload Only) In this example you can set a local folder with sub-folders to sync with a File Management virtual library. First run will upload and update all files and create a lastRunTime.json file for reference of last run. On the next run only files that the update date is larger than the last run time of the application will be uploaded/updated Config.ini file sample: [DEFAULT] # Sisense URL host = https://test.sisense.com # Path to store files on target machine remoteLocation= data/Test # Path to folder or file which should be transferred # If folder is specifeed, all subfolders will be also proccessed path = C:\Users\Documents\Test\ # Sisense API token token = Bearer TOKEN # Script will store last modified time for each processed file. This will allow it to upload only modified files on next executions lastRunFilename = lastRunTime.json Droppy.py file sample: Droppy.py example Version <=L2021.3 import uuid import requests import io import json import os import time from datetime import datetime import configparser config = configparser.ConfigParser() config.read('config.ini') lastRunFilename = config.get('DEFAULT','lastRunFilename') host = config.get('DEFAULT','host') remoteLocation = config.get('DEFAULT','remoteLocation') path = config.get('DEFAULT','path') token = config.get('DEFAULT','token') # Cut slashes at the end of paths if they are exist if path[-1] == '\\': path = path[:-1] if remoteLocation[-1] == '/': remoteLocation = remoteLocation[:-1] # Function to compare stored and file last modified time def compareModificationTime(filePath): if (filePath in lastRunTime and os.path.getmtime(filePath)>int(lastRunTime.get(filePath))) or (filePath not in lastRunTime): return True else: return False # Function to upload file to Droppy via Sisense API def uploadFile (filesNames, folderPath): if os.path.isfile(path): globalFolderPath = os.path.dirname(path) else: globalFolderPath = path if folderPath != globalFolderPath: remotePath = remoteLocation + folderPath.replace(globalFolderPath,'') else: remotePath = remoteLocation remotePath = remotePath.replace('\\','/') url = host +'/app/explore/!/upload?vId=0&rename=0&to=/'+remotePath files = [] header = {'Authorization': token} notSentFiles = [] for filename in filesNames: filePath = '%s\\%s'%(folderPath, filename) if compareModificationTime(filePath): files.append( ("file", ( open(filePath, "rb")))) lastRunTime [filePath] = int(time.time()) else: notSentFiles.append(filePath) if files: r = requests.post(url, files=files, headers=header) for filename in filesNames: print(remotePath+'/'+filename, r.status_code, r.reason) return notSentFiles try: f = open(lastRunFilename, "r") timestamp = f.read() lastRunTime = json.loads(timestamp) except: lastRunTime = {} notSentFiles=[] if ( os.path.isdir(path)): for root, subdirs, files in os.walk(path): if files: notSentFiles += uploadFile (files, root) time.sleep(0.1) elif ( os.path.isfile(path)): notSentFiles += uploadFile ([os.path.basename(path)], path.rsplit('\\', 1)[0]) elif not os.path.exists(path): print ("Specified path doesn't exist") if notSentFiles: print ('These files were not uploaded because they were not modified:') for file in notSentFiles: print (file) with open(lastRunFilename, 'w') as f: json.dump(lastRunTime, f) Version >= L2021.5 import uuid import requests import io import json import os import time from datetime import datetime import configparser config = configparser.ConfigParser() config.read('config.ini') lastRunFilename = config.get('DEFAULT','lastRunFilename') host = config.get('DEFAULT','host') remoteLocation = config.get('DEFAULT','remoteLocation') path = config.get('DEFAULT','path') token = config.get('DEFAULT','token') # Cut slashes at the end of paths if they are exist if path[-1] == '\\': path = path[:-1] if remoteLocation[-1] == '/': remoteLocation = remoteLocation[:-1] # Function to compare stored and file last modified time def compareModificationTime(filePath): if (filePath in lastRunTime and os.path.getmtime(filePath)>int(lastRunTime.get(filePath))) or (filePath not in lastRunTime): return True else: return False # Function to upload file to Droppy via Sisense API def uploadFile (filesNames, folderPath): def get_auth(token): headers = { 'Authorization': token, } x_auth = requests.post(f'{host}/app/explore/api/login', headers=headers) if x_auth.status_code==200: return x_auth.text else: print ('Cannot get x-auth token. Check API token validity') return False # # SERVICE FUNCTION # # Do NOT modify x_auth = get_auth(token) if os.path.isfile(path): globalFolderPath = os.path.dirname(path) else: globalFolderPath = path if folderPath != globalFolderPath: remotePath = remoteLocation + folderPath.replace(globalFolderPath,'') else: remotePath = remoteLocation remotePath = remotePath.replace('\\','/') files = [] header = {'Authorization': token, 'x-auth': x_auth,} notSentFiles = [] for filename in filesNames: filePath = '%s\\%s'%(folderPath, filename) if compareModificationTime(filePath): files.append(filePath) lastRunTime [filePath] = int(time.time()) else: notSentFiles.append(filePath) if files: for file in files: with open(file,'rb') as ff: file=os.path.basename(file) r = requests.post(f'{host}/app/explore/api/resources/{remotePath}/{file}?override=true', headers=header,data=ff) print(remotePath+'/'+file, r.status_code, r.reason) return notSentFiles try: f = open(lastRunFilename, "r") timestamp = f.read() lastRunTime = json.loads(timestamp) except: lastRunTime = {} notSentFiles=[] if ( os.path.isdir(path)): for root, subdirs, files in os.walk(path): if files: notSentFiles += uploadFile (files, root) time.sleep(0.1) elif ( os.path.isfile(path)): notSentFiles += uploadFile ([os.path.basename(path)], path.rsplit('\\', 1)[0]) elif not os.path.exists(path): print ("Specified path doesn't exist") if notSentFiles: print ('These files were not uploaded because they were not modified:') for file in notSentFiles: print (file) with open(lastRunFilename, 'w') as f: json.dump(lastRunTime, f) File Management (Upload, Delete, Download, Rename Etc)3.3KViews0likes0Comments