--- a/trunk/cforge/cforge/Package/CFORGE/Scripts/checkout-prj.py +++ b/trunk/cforge/cforge/Package/CFORGE/Scripts/checkout-prj.py @@ -1,8 +1,19 @@ import sys, os -import ui import pysvn import json -from System.Net import WebClient + +hasWebClient = True +try: + from System.Net import WebClient +except: + import requests + hasWebClient = False + +hasUI = True +try: + import ui +except: + hasUI = False base_url = "https://forge.codesys.com/rest" base_svn = "https://forge.codesys.com/svn/" @@ -23,12 +34,16 @@ return help def get_json(url): - web_client = WebClient() - r = web_client.DownloadData(url) + r = "" + if hasWebClient: + web_client = WebClient() + r = web_client.DownloadData(url) + else: + r = requests.get(url).content + j = json.loads(bytes(r).decode('utf-8')) return j - if len(sys.argv) <= 1: print("Oh, there are no arguments. Perhaps you forgot something?") sys.exit() @@ -44,7 +59,7 @@ config['user'] = sys.argv[2] config['pass'] = sys.argv[3] config['folder'] = sys.argv[4] -else: +elif hasUI: config = ui.Dialog("Checkout Project", Folder=True, Credentials=True, DefaultFolder=folder) # iterate over all tools of the project, and checkout all SVN repositories,