diff --git a/OpenBench/urls.py b/OpenBench/urls.py index b03a5af..53d06bf 100644 --- a/OpenBench/urls.py +++ b/OpenBench/urls.py @@ -54,6 +54,9 @@ urlpatterns = [ django.urls.path(r'networks//', OpenBench.views.networks), django.urls.path(r'networks///', OpenBench.views.networks), + # Links for interacting with OpenBench via scripting + django.urls.path(r'scripts/', OpenBench.views.scripts), + # Links for the Client to work with the Server django.urls.path(r'clientGetFiles/', OpenBench.views.clientGetFiles), django.urls.path(r'clientGetBuildInfo/', OpenBench.views.clientGetBuildInfo), diff --git a/OpenBench/views.py b/OpenBench/views.py index 4090be4..d2c57f0 100644 --- a/OpenBench/views.py +++ b/OpenBench/views.py @@ -580,6 +580,21 @@ def networks(request, action=None, sha256=None, client=False): return response +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# OPENBENCH SCRIPTING # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + +@csrf_exempt +def scripts(request): + + login(request) # All requests are attached to a User + + if request.POST['action'] == 'UPLOAD': + return networks(request, action='UPLOAD') + + if request.POST['action'] == 'CREATE_TEST': + return newTest(request) + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # CLIENT HOOK VIEWS # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # diff --git a/Scripts/create_test.py b/Scripts/create_test.py new file mode 100644 index 0000000..2f3038e --- /dev/null +++ b/Scripts/create_test.py @@ -0,0 +1,48 @@ +import requests + +# Basic Information: +# Test options must contain 'Threads={} Hash={}' +# Test Modes may either be of type 'SPRT' or 'GAMES' +# Syzygy settings are { 'OPTIONAL', 'REQUIRED', 'DISABLED' } +# Max Games is ignored unless test is of type 'GAMES' +# Networks must be assigned using their SHA256, not their name +# Networks with the value '' are used for tests without Networks + +URL = 'http://chess.grantnet.us/scripts/' + +data = { + + 'enginename' : '', + 'source' : '', + + 'devbench' : '', + 'devbranch' : '', + 'devoptions' : ' + 'devnetwork' : '', + + 'basebench' : '', + 'basebranch' : '', + 'baseoptions' : '', + 'basenetwork' : '', + + 'bookname' : '', + 'timecontrol' : '', + + 'test_mode' : '', + 'bounds' : '', + 'confidence' : '', + 'max_games' : '', + + 'priority' : '', + 'throughput' : '', + 'syzygy_adj' : '', + 'syzygy_wdl' : '', + + 'username' : '', + 'password' : '', + 'action' : 'CREATE_TEST', +} + +r = requests.post(URL, data=data) + +print(r.text) \ No newline at end of file diff --git a/Scripts/upload_net.py b/Scripts/upload_net.py new file mode 100644 index 0000000..365f5f7 --- /dev/null +++ b/Scripts/upload_net.py @@ -0,0 +1,17 @@ +import requests + +URL = 'http://chess.grantnet.us/scripts/' +FILENAME = '' + +data = { + 'engine' : '', + 'name' : ''. + 'username' : '', + 'password' : '', + 'action' : 'UPLOAD', +} + +with open(FILENAME, 'rb') as file: + r = requests.post(URL, data=data, files={'netfile' : file}) + +print(r.text) \ No newline at end of file