* pyupgrade
* various new codemods
* manual removal of Py2/3 compat imports
* manual adjustment of docs, examples, tests
* to_str is now the new to_unicode, deprecated
redirection to to_bytes has been removed
* to_native_str has been redirected to point to
to_str
* to_unicode has been redirected to point to
to_str
* atomic_write refactored to use
NamedTemporaryDirectory
* various other fixes/refactorings all over the
place
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
__author__ = "Marc Hannappel <salandora@gmail.com>"
|
|
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
|
__copyright__ = "Copyright (C) 2017 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
|
|
|
# Wrapper to the new access.users location
|
|
|
|
import warnings
|
|
|
|
from octoprint.access.users import * # noqa: F401, F403 ## possibly used by other modules
|
|
from octoprint.access.users import User, deprecated
|
|
|
|
warnings.warn(
|
|
"octoprint.users is deprecated, use octoprint.access.users instead",
|
|
DeprecationWarning,
|
|
stacklevel=2,
|
|
)
|
|
|
|
AccessUser = User
|
|
|
|
|
|
class User(AccessUser):
|
|
@deprecated(
|
|
"octoprint.users.User is deprecated, please use octoprint.access.users.User instead"
|
|
)
|
|
def __init__(self, username, passwordHash, active, roles, apikey=None, settings=None):
|
|
from octoprint.server import groupManager
|
|
|
|
if "admin" in roles:
|
|
groups = [groupManager.admin_group]
|
|
elif "user" in roles:
|
|
groups = [groupManager.user_group]
|
|
else:
|
|
groups = [groupManager.guest_group]
|
|
|
|
AccessUser(
|
|
username=username,
|
|
passwordHash=passwordHash,
|
|
active=active,
|
|
permissions=None,
|
|
groups=groups,
|
|
apikey=apikey,
|
|
settings=settings,
|
|
)
|