Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add login option using token #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
colorama==0.3.9
nose==1.3.7
PyYAML>=3.12,<4
PyYAML>=6.0.1
requests>=2.18.3,<3
Requires==0.0.3
screepsapi>=0.5.1
screepsapi @ git+https://github.com/screepers/python-screeps@b4dd23c4d7d987ea73bfc53faca445abd4f5b58d
six>=1.10.0,<2
urwid==1.3.1
urwid==2.1.2
websocket-client==0.44.0
5 changes: 3 additions & 2 deletions screeps_console/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,15 +401,16 @@ def __del__(self):
connectionSettings = settings.getConnection(server)

if not connectionSettings:
if server is 'main':
if server == 'main':
host = 'screeps.com'
secure = True
else:
host = input("Host: ")
secure = input("Secure (y/n) ") == "y"
username = input("Username: ")
password = input("Password: ")
settings.addConnection(server, username, password, host, secure)
token = input("Token: ")
settings.addConnection(server, username, password, token, host, secure)

if server == 'main' and 'token' not in connectionSettings:
settings.addConnection('main', connectionSettings['username'], connectionSettings['password'])
Expand Down
6 changes: 3 additions & 3 deletions screeps_console/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def getSettings():
saveSettings(settings)
return settings
with open(settingsfile, 'r') as f:
settings = yaml.load(f)
settings = yaml.safe_load(f)
return settings


Expand All @@ -41,7 +41,7 @@ def getConnection(name):
return settings['connections'][name]


def addConnection(name, username, password, host=False, secure=False):
def addConnection(name, username, password, token=False, host=False, secure=False):
if name == 'main':
secure = True
host = 'screeps.com'
Expand All @@ -58,7 +58,7 @@ def addConnection(name, username, password, host=False, secure=False):
settings['connections'] = {}

if name == 'main' or name == 'ptr':
token = getToken(username, password, host, secure)
token = token if token else getToken(username, password, host, secure)
settings['connections'][name] = {
'host': host,
'secure': secure,
Expand Down