From 740bb07a6440c18cd4ea402ae1735a51a2d749f1 Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Tue, 21 May 2019 18:09:05 +0100 Subject: [PATCH] starting to abuse classes less --- Py3CX/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Py3CX/__init__.py b/Py3CX/__init__.py index 1228cba..23e9e25 100644 --- a/Py3CX/__init__.py +++ b/Py3CX/__init__.py @@ -251,7 +251,6 @@ class Py3CX: self.uname=getenv(ENV_AUTH_USER, None) self.passw=getenv(ENV_AUTH_PASS, None) self.rq=Request(uri=self.uri, verify=tls_verify) - def authenticate(self, username=None, password=None): if username is not None and password is not None: self.uname=username @@ -261,7 +260,6 @@ class Py3CX: 'Username': self.uname, 'Password': self.passw}) self.rq.sess.headers.update({'x-xsrf-token':rs.cookies['XSRF-TOKEN']}) - @property def authenticated(self): try: @@ -269,4 +267,10 @@ class Py3CX: except APIError: return False return True + @property + def System(self): + assert self.authenticated, "Py3CX not authenticated yet!" + if self.tcxsystem is None: + self.tcxsystem=PhoneSystem(self) + return self.tcxsystem