Skip to content
Permalink
Browse files

CSV (Python) Dynamic Folder Sample

  • Loading branch information...
lemonmojo committed Aug 20, 2018
1 parent 3a51573 commit 79a6db772cb00c412c58633959e65c8550b62ff4
Showing with 1 addition and 0 deletions.
  1. +1 −0 Dynamic Folder/CSV/CSV (Python).rdfe
@@ -0,0 +1 @@
{"Name":"Dynamic Folder Export","Objects":[{"Type":"DynamicFolder","Name":"CSV (Python)","Notes":"<h2><strong>Dynamic Folder sample for CSV</strong></h2>\n\n<p><strong>Version</strong>: 1.0<br />\n<strong>Author</strong>: Royal Applications</p>\n\n<p>This Dynamic Folder sample for CSV files allows you to import connections from a CSV file.</p>\n\n<h3><strong>Setup</strong></h3>\n\n<ul>\n\t<li>Enter the path to your CSV file in the &quot;CSV Path&quot; field in the &quot;Custom Properties&quot; section.</li>\n</ul>\n","CustomProperties":[{"Name":"CSV Path","Type":"URL","Value":"TODO"}],"ScriptInterpreter":"python","DynamicCredentialScriptInterpreter":"json","Script":"import os\nimport csv\nimport json\n\ndef get_entries(csv_path):\n csvfile = open(os.path.expanduser(csv_path))\n reader = csv.DictReader(csvfile)\n\n connections = []\n\n for row in reader:\n name = row[\"Name\"]\n computerName = row[\"ComputerName\"]\n username = row[\"Username\"]\n password = row[\"Password\"]\n\n connection = {\n \"Type\": \"TerminalConnection\",\n \"TerminalConnectionType\": \"SSH\",\n \"Name\": name,\n \"ComputerName\": computerName,\n \"Username\": username,\n \"Password\": password\n }\n\n connections.append(connection)\n\n store = {\n \"Objects\": connections\n }\n\n store_json = json.dumps(store)\n\n return store_json\n\nprint(get_entries(\"$CustomProperty.CSVPath$\"))"}]}

0 comments on commit 79a6db7

Please sign in to comment.
You can’t perform that action at this time.