def on_login(self): """Perform login with current settings in the dialog.""" host = self.inputs["host"].text() user = self.inputs["user"].text() password = self.inputs["password"].text() try: gazu.set_host(host) result = gazu.log_in(user, password) except Exception as exc: message = str(exc) if message.startswith("('auth/login',"): # Failed to login message = "Login verification failed.\n" \ "Please ensure your username and " \ "password are correct." else: # Something else happened. # For readability produce new line # around every dot with following space message = message.replace(". ", ".\n") self.error.setText(message) self.error.show() return if result: name = "{user[first_name]} {user[last_name]}".format(**result) log.info("Logged in as %s.." % name) self.accept()
def Connect(self, host, user, password, projectName): """Log-in dialog to Kitsu""" # Connect to server if self.tokens is None: try: host = removeLastSlash(host) host = host + "/api" gazu.set_host(host) if not gazu.client.host_is_up(): raise ConnectionError( "Could not connect to the server. Is the host URL correct?" ) except Exception as exc: QMessageBox.warning(QWidget(), str("Kitsu Error"), str(exc)) return "Connection error" # Login try: self.tokens = gazu.log_in(user, password) except: message = ("Login verification failed.\n" "Please ensure your username and " "password for Kitsu are correct.\n") QMessageBox.warning(QWidget(), str("Kitsu Error"), str(message)) return "Connection error" QMessageBox.warning(QWidget(), str("Kitsu Logged in"), str("Logged in")) # Lastly, get the project dict and return it project_dict = gazu.project.get_project_by_name(projectName) return project_dict
def init_events_listener(target, event_target, login, password, logs_dir=None): """ Set parameters for the client that will listen to events from the target. """ gazu.set_event_host(event_target) gazu.set_host(target) gazu.log_in(login, password) if logs_dir is not None: set_logger(logs_dir) return gazu.events.init()
def main(): try: app = create_app() host = os.environ.get("CGWIRE_HOST", None) login = os.environ.get("CGWIRE_LOGIN", None) password = os.environ.get("CGWIRE_PASSWORD", None) if login is not None and password is not None: gazu.set_host(host) gazu.log_in(login, password) launch_main_window(app) else: login_window = create_login_window(app) login_window.show() launch_app(app) except KeyboardInterrupt: sys.exit()
def login(self, host, username, password, switch=None): switch_window = QtCore.pyqtSignal() try: gazu.set_host(host) gazu.log_in(username, password) if switch != None: switch.emit() if self.debug == True: return gazu.log_in(username, password)['user']['full_name'] except (NotAuthenticatedException, ParameterException): if self.debug is False: error = QMessageBox() error.setWindowTitle('Login Error') error.setText('Login failure, Wrong credentials. pls check login details or host') error.setIcon(QMessageBox.Critical) error.exec_() else: return 'Login failure, Wrong credentials. pls check login details or host' except (MethodNotAllowedException, RouteNotFoundException, InvalidURL): if self.debug is False: error = QMessageBox() error.setWindowTitle('Login Error') error.setText('invalid host url') error.setIcon(QMessageBox.Critical) error.exec_() else: return 'invalid host url' except (MissingSchema, InvalidSchema, ConnectionError) as err: if self.debug is False: error = QMessageBox() error.setWindowTitle('Login Error') error.setText(str(err)) error.setIcon(QMessageBox.Critical) error.exec_() else: return 'bad schema or bad connection' except Exception as e: if self.debug is False: error = QMessageBox() error.setWindowTitle('Login Error') error.setText('something went wrong: ' + str(e)) error.setIcon(QMessageBox.Critical) error.exec_() else: return 'Login Error. something went wrong'
def on_login(self): """Perform login with current settings in the dialog.""" host = self.inputs["host"].text() user = self.inputs["user"].text() password = self.inputs["password"].text() try: gazu.set_host(host) if not gazu.client.host_is_up(): raise ConnectionError( "Could not connect to the server. Is the host URL correct?" ) result = gazu.log_in(user, password) except Exception as exc: message = str(exc) if message.startswith("auth/login"): message = ( "Could not connect to the server. Is the host URL correct?" ) if message.startswith("('auth/login',"): # Failed to login message = ("Login verification failed.\n" "Please ensure your username and " "password are correct.") else: # Something else happened. # For readability produce new line # around every dot with following space message = message.replace(". ", ".\n") self.error.setText(message) self.error.show() self.error.start_animation() self.logged_in.emit(False) return if result: name = "{user[first_name]} {user[last_name]}".format(**result) log.info("Logged in as %s.." % name) self.logged_in.emit(True) self.accept()
def main(): try: app = create_app() host = os.environ.get("CGWIRE_HOST", None) login = os.environ.get("CGWIRE_LOGIN", None) password = os.environ.get("CGWIRE_PASSWORD", None) host = "http://localhost/api" login = "******" password = "******" if login is not None and password is not None: gazu.set_host(host) gazu.log_in(login, password) launch_main_window(app) else: login_window = create_login_window(app) login_window.show() launch_app(app) except KeyboardInterrupt: sys.exit()
def on_login(self): """Perform login with current settings in the dialog.""" host = self.inputs["host"].text() user = self.inputs["user"].text() password = self.inputs["password"].text() try: gazu.set_host(host) if not gazu.client.host_is_valid(): raise ConnectionError( "Could not connect to the server.\nIs the host URL correct?" ) result = gazu.log_in(user, password) except ConnectionError: message = "Could not connect to the server.\nIs the host URL correct?" self.show_error(message) return except gazu.exception.ParameterException: message = ( "Login verification failed.\n" "Please ensure your username and " "password are correct." ) self.show_error(message) return except Exception: # In case of unexpected exception, show the traceback message = traceback.format_exc() self.show_error(message) return if result: name = "{user[first_name]} {user[last_name]}".format(**result) log.info("Logged in as %s.." % name) self.logged_in.emit(True) self.accept() else: message = "Unexpected behaviour : Did not retrieve user informations" self.show_error(message)
def init(target, login, password): """ Set parameters for the client that will retrieve data from the target. """ gazu.set_host(target) gazu.log_in(login, password)
def test_init_host(self): gazu.set_host("newhost") self.assertEqual(gazu.get_host(), "newhost") gazu.set_host("http://gazu-server/") self.assertEqual(gazu.get_host(), gazu.client.HOST)
def test_init_host(self): gazu.set_host("newhost") self.assertEqual(gazu.get_host(), "newhost") gazu.set_host("http://gazu-server/") self.assertEqual(gazu.get_host(), gazu.raw.default_client.host)
import gazu gazu.set_host("http://localhost/api") gazu.log_in("*****@*****.**", "default") bbb = gazu.project.new_project("Big Buck Bunny") agent327 = gazu.project.new_project("Agent 327") caminandes = gazu.project.new_project("Caminandes Llamigos") characters = gazu.asset.new_asset_type("Characters") props = gazu.asset.new_asset_type("Props") environment = gazu.asset.new_asset_type("Props") fx = gazu.asset.new_asset_type("FX") asset_desc = [(characters, "Lama"), (characters, "Baby Pingoo"), (characters, "Pingoo"), (environment, "Mine"), (environment, "Pool"), (environment, "Railroad"), (fx, "smoke"), (fx, "wind"), (props, "berry"), (props, "flower")] assets = [] shots = [] for (asset_type, asset_name) in asset_desc: assets.append(gazu.asset.new_asset(caminandes, asset_type, asset_name)) for episode_name in ["E01", "E02", "E03"]: episode = gazu.shot.new_episode(caminandes, episode_name) for sequence_name in ["SE01", "SE02", "SE03"]: sequence = gazu.shot.new_sequence(caminandes, episode, sequence_name)
import gazu gazu.set_host("http://*****:*****@doe.com", "password") def my_callback(data): print("Task status changed:") print(data) try: event_client = gazu.events.init() gazu.events.add_listener(event_client, "task:status-changed", my_callback) gazu.events.run_client(event_client) except KeyboardInterrupt: print("Stop listening.") except TypeError: print("Authentication failed. Please verify your credentials.")
def login_kitsu(self, refresh, progress_callback): self.l_info.setText("Logging in") # Connect to server if self.gazuToken is None or refresh is True: try: host = self.le_kitsuURL.text() host = removeLastSlash(host) host = host + "/api" gazu.set_host(host) if not gazu.client.host_is_up(): raise ConnectionError( "Could not connect to the server. Is the host URL correct?" ) except Exception as exc: template = "An exception of type {0} occurred. Arguments:\n{1!r}" message = template.format(type(exc).__name__, exc.args) return message # Login try: self.gazuToken = gazu.log_in(self.le_username.text(), self.le_password.text()) except Exception as exc: message = ("Login verification failed. " "Please ensure your username and " "password for Kitsu are correct. ") template = "An exception of type {0} occurred. Arguments:\n{1!r}" message = template.format(type(exc).__name__, message) return message # Logged in. Let's fetch the projects! try: self.cb_project.setEnabled(True) self.l_project.setEnabled(True) self.cb_project.clear() projects = gazu.project.all_projects() for index, project in enumerate(projects): self.cb_project.insertItem(index, project["name"], userData=project) except Exception as exc: template = "An exception of type {0} occurred. Arguments:\n{1!r}" message = template.format(type(exc).__name__, exc.args) return message # and let's fetch the shot task types try: self.cb_task.setEnabled(True) self.l_task.setEnabled(True) self.cb_task.clear() task_types = gazu.task.all_task_types() for index, task_type in enumerate(task_types): if task_type["for_shots"] is True: self.cb_task.insertItem(index, task_type["name"], userData=task_type) except Exception as exc: template = "An exception of type {0} occurred. Arguments:\n{1!r}" message = template.format(type(exc).__name__, exc.args) return message # and let's fetch the statuses try: self.cb_status.setEnabled(True) self.l_status.setEnabled(True) self.cb_status.clear() all_task_statuses = gazu.task.all_task_statuses() for index, all_task_status in enumerate(all_task_statuses): self.cb_status.insertItem(index, all_task_status["name"], userData=all_task_status) except Exception as exc: template = "An exception of type {0} occurred. Arguments:\n{1!r}" message = template.format(type(exc).__name__, exc.args) return message return True return False