Play script

This commit is contained in:
adithyagenie 2023-01-18 07:55:21 +05:30
parent 690abbd798
commit 4519aedca8
8 changed files with 87 additions and 2 deletions

0
.fleet/settings.json Normal file
View file

5
.gitignore vendored
View file

@ -6,4 +6,7 @@ maze/__pycache__
maze/modules/__pycache__ maze/modules/__pycache__
saves saves
tetris tetris
wordle-curses/__pycache__ wordle-curses/__pycache__
1.json
2.json
3.json

View file

View file

1
helper_scripts/play.bat Normal file
View file

@ -0,0 +1 @@
start python %~f1/starter.py

37
play.bat Normal file
View file

@ -0,0 +1,37 @@
:: Play the game
@ECHO off
cls
:start
ECHO.
ECHO 1. Play game
ECHO 2. Initialise SQL login creds
ECHO 3. Dump sample data
ECHO 4. Exit
set choice=
set /p choice=Choice?
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto play
if '%choice%'=='2' goto initsql
if '%choice%'=='3' goto dump
if '%choice%'=='4' goto end
ECHO "%choice%" is not valid, try again
ECHO.
goto start
:play
start cmd /c "python %~dp0%~1/starter.py"
move nul 2>&0
goto end
:initsql
start cmd /c "python %~dp0%~1/starter.py initsql"
move nul 2>&0
goto end
:dump
start cmd /c "python %~dp0%~1/starter.py dumpsample"
move nul 2>&0
goto end
:end
pause

39
play.vbs Normal file
View file

@ -0,0 +1,39 @@
strTitle = "Labyrinth"
strMsg = "1. Play" & vbCr
strMsg = strMsg & "2. Initialise SQL creds" & vbCR
strMsg = strMsg & "3. Dump sample data" & vbCR
strMsg = strMsg & "Select choice:" & vbCR
Dim oShell
Set oShell = WScript.CreateObject ("WScript.Shell")
Dim folderName
folderName = "."
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim fullpath
fullpath = fso.GetAbsolutePathName(folderName)
const quote = """"
Dim command
Do
inp01 = InputBox(strMsg,strTitle)
OK = True
Select Case inp01
Case "1"
command = quote + "C:\Program Files\PowerShell\7\pwsh.exe" & quote & "-ExecutionPolicy ByPass -NoExit -Command & " & quote & "E:\Programs\Miniconda3\shell\condabin\conda-hook.ps1" & quote & "; conda activate " & quote & "E:\Programs\Miniconda3" & quote & "; conda activate adi; python " & fullpath & "\starter.py"
command = "cmd.exe /C python "+fullpath+"\starter.py"
msgBox command
oShell.run ""+command
Case "2"
command = quote + "C:\Program Files\PowerShell\7\pwsh.exe" & quote & "-ExecutionPolicy ByPass -NoExit -Command & " & quote & "E:\Programs\Miniconda3\shell\condabin\conda-hook.ps1" & quote & "; conda activate " & quote & "E:\Programs\Miniconda3" & quote & "; conda activate adi; python " & fullpath & "\starter.py initsql"
command = "cmd.exe /C python "+fullpath+"\starter.py initsql"
oShell.run ""+command
Case "3"
command = quote + "C:\Program Files\PowerShell\7\pwsh.exe" & quote & "-ExecutionPolicy ByPass -NoExit -Command & " & quote & "E:\Programs\Miniconda3\shell\condabin\conda-hook.ps1" & quote & "; conda activate " & quote & "E:\Programs\Miniconda3" & quote & "; conda activate adi; python " & fullpath & "\starter.py dumpsample"
command = "cmd.exe /C python "+fullpath+"\starter.py dumpsample"
oShell.run ""+command
Case ""
WScript.quit
Case Else
MsgBox "You made an incorrect selection!",64,strTitle
OK = False
End Select
Loop While Not OK

View file

@ -1,5 +1,5 @@
import pickle import pickle
import json
import requests import requests
with open("credentials.pickle", "rb") as f: with open("credentials.pickle", "rb") as f:
@ -9,6 +9,7 @@ with open("credentials.pickle", "rb") as f:
if d["credtype"] == "oxfordapi": if d["credtype"] == "oxfordapi":
app_id = d["app_id"] app_id = d["app_id"]
app_key = d["app_key"] app_key = d["app_key"]
break
except EOFError: except EOFError:
pass pass
@ -17,6 +18,7 @@ language = "en-us"
def defnsyn(w): def defnsyn(w):
"""Returns definition and synonym of said word""" """Returns definition and synonym of said word"""
f = open("log.txt", "a")
url = ( url = (
r"https://od-api.oxforddictionaries.com:443/api/v2/entries/" r"https://od-api.oxforddictionaries.com:443/api/v2/entries/"
+ language + language
@ -25,13 +27,16 @@ def defnsyn(w):
) )
r = requests.get(url, headers={"app_id": app_id, "app_key": app_key}) r = requests.get(url, headers={"app_id": app_id, "app_key": app_key})
if r.status_code != 200: if r.status_code != 200:
f.write("GOT "+str(r.status_code))
return None, None return None, None
res = r.json() res = r.json()
f.write(json.dumps(res))
s1 = res["results"][0]["lexicalEntries"] s1 = res["results"][0]["lexicalEntries"]
lexicalCategories = [] lexicalCategories = []
synonyms = [] synonyms = []
defn = "" defn = ""
try: try:
defn = res["entries"]["senses"]["definitions"][0]
if len(s1) > 1: if len(s1) > 1:
for i in range(len(s1)): for i in range(len(s1)):
lexicalCategories.append(s1[i]["lexicalCategory"]["id"]) lexicalCategories.append(s1[i]["lexicalCategory"]["id"])