| 348 | self.config["webinterface"]["https"] = ssl |
| 349 | |
| 350 | def set_user(self): |
| 351 | gettext.setpaths([os.path.join(os.sep, "usr", "share", "pyload", "locale"), None]) |
| 352 | translation = gettext.translation("setup", os.path.join(self.path, "locale"), |
| 353 | languages=[self.config["general"]["language"], "en"], fallback=True) |
| 354 | translation.install(True) |
| 355 | |
| 356 | from module.database import DatabaseBackend |
| 357 | |
| 358 | db = DatabaseBackend(None) |
| 359 | db.setup() |
| 360 | |
| 361 | noaction = True |
| 362 | try: |
| 363 | while True: |
| 364 | print _("Select action") |
| 365 | print _("1 - Create/Edit user") |
| 366 | print _("2 - List users") |
| 367 | print _("3 - Remove user") |
| 368 | print _("4 - Quit") |
| 369 | action = raw_input("[1]/2/3/4: ") |
| 370 | if not action in ("1", "2", "3", "4"): |
| 371 | continue |
| 372 | elif action == "1": |
| 373 | print "" |
| 374 | username = self.ask(_("Username"), "User") |
| 375 | password = self.ask("", "", password=True) |
| 376 | db.addUser(username, password) |
| 377 | noaction = False |
| 378 | elif action == "2": |
| 379 | print "" |
| 380 | print _("Users") |
| 381 | print "-----" |
| 382 | users = db.listUsers() |
| 383 | noaction = False |
| 384 | for user in users: |
| 385 | print user |
| 386 | print "-----" |
| 387 | print "" |
| 388 | elif action == "3": |
| 389 | print "" |
| 390 | username = self.ask(_("Username"), "") |
| 391 | if username: |
| 392 | db.removeUser(username) |
| 393 | noaction = False |
| 394 | elif action == "4": |
| 395 | break |
| 396 | finally: |
| 397 | if not noaction: |
| 398 | db.shutdown() |
| 399 | |
| 400 | def conf_path(self, trans=False): |
| 401 | if trans: |