コード例 #1
0
def setup_i18n():
	import locale
	locale.setlocale(locale.LC_ALL, "")
	from univention.lib.i18n import Translation
	translation = Translation('univention-system-setup-scripts')
	translation.set_language()
	return translation.translate
コード例 #2
0
# <http://www.gnu.org/licenses/>.

from ldap.filter import filter_format
from univention.lib.i18n import Translation

from univention.management.console.modules import UMC_Error
from univention.management.console.modules.decorators import sanitize
from univention.management.console.modules.sanitizers import ListSanitizer, DictSanitizer, StringSanitizer
from univention.management.console.log import MODULE

import univention.admin.uexceptions as udm_exceptions

from ucsschool.lib.schoolldap import LDAP_Connection, SchoolBaseModule, Display, USER_READ, USER_WRITE, MACHINE_WRITE, SchoolSanitizer
from ucsschool.lib.models import User, Teacher, TeachersAndStaff, SchoolClass, WorkGroup

_ = Translation('ucs-school-umc-groups').translate


def only_workgroup_admin(func):
    def _decorated(self, request, *args, **kwargs):
        if request.flavor != 'workgroup-admin':
            raise UMC_Error('not supported')
        return func(self, request, *args, **kwargs)

    return _decorated


def get_group_class(request):
    if request.flavor in ('workgroup', 'workgroup-admin'):
        return WorkGroup
    elif request.flavor == 'teacher':
コード例 #3
0
#!/usr/bin/python
# taken from https://git.knut.univention.de/univention/ucsschool/blob/842f439e29d8415ff5b9bd5f293ef3a5c980f660/ucs-school-umc-printermoderation/umc/python/printermoderation/__init__.py#L151
# bugzilla Bug 38270
# Fixed in UCS@school 4.0 R2

import os

from univention.lib.i18n import Translation
from univention.management.console.modules import UMC_Error
from ucsschool.lib import SchoolBaseModule

CUPSPDF_DIR = '/var/spool/cups-pdf/'
CUPSPDF_USERSUBDIR = None

_ = Translation('ucs-school-umc-printermoderation').translate


class Instance(SchoolBaseModule):
    def download(self, request):
        """Download a printjob of a specified user

		requests.options = {}
		'username' -- owner of the print job
		'filename' -- relative filename of the print job

		return: <PDF document>
		"""
        if request.options['username'].find(
                '/') > 0 or request.options['printjob'].find('/') > 0:
            raise UMC_Error('Invalid file')
コード例 #4
0
import subprocess
from contextlib import contextmanager
import threading
from logging import getLogger, DEBUG, Handler
from time import sleep

import apt_pkg
import apt
import apt.progress
from apt.cache import FetchFailedException, LockFailedException, ProblemResolver

apt_pkg.init()

from univention.lib.locking import get_lock, release_lock
from univention.lib.i18n import Translation
_ = Translation('univention-lib').translate

# FIXME: Requires univention-updater (but this requires univention-lib...)
# FIXME: The path to the script is hardcoded everywhere it is used.
# TODO: Solution: Put all the logic in univention-lib
CMD_DISABLE_EXEC = '/usr/share/univention-updater/disable-apache2-umc'
CMD_ENABLE_EXEC = [
    '/usr/share/univention-updater/enable-apache2-umc', '--no-restart'
]


class LockError(Exception):
    """
	Lock error for the package manager.
	Not to be confused with :py:class:`LockFailedException`
	"""
コード例 #5
0
ファイル: azure_auth.py プロジェクト: Rabie-Zamane/office365
from cryptography.x509 import load_pem_x509_certificate
from cryptography.hazmat.backends import default_backend
import OpenSSL.crypto
import jwt
from requests.exceptions import RequestException
import subprocess
import shutil

from univention.lib.i18n import Translation
from univention.office365.logging2udebug import get_logger
from univention.office365.udm_helper import UDMHelper
from univention.config_registry.frontend import ucr_update
from univention.config_registry import ConfigRegistry, handler_set, handler_unset


_ = Translation('univention-office365').translate

NAME = "office365"
SCOPE = ["Directory.ReadWrite.All"]  # https://msdn.microsoft.com/Library/Azure/Ad/Graph/howto/azure-ad-graph-api-permission-scopes#DirectoryRWDetail
DEBUG_FORMAT = '%(asctime)s %(levelname)-8s %(module)s.%(funcName)s:%(lineno)d  %(message)s'
LOG_DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'
SAML_SETUP_SCRIPT_CERT_PATH = "/etc/simplesamlphp/ucs-sso.{domainname}-idp-certificate{adconnection_alias}.crt"
SAML_SETUP_SCRIPT_PATH = "/var/lib/univention-office365/saml_setup{adconnection_alias}.bat"
ADCONNECTION_CONF_BASEPATH = "/etc/univention-office365"

oauth2_auth_url = "https://login.microsoftonline.com/{adconnection}/oauth2/authorize?{params}"
oauth2_token_url = "https://login.microsoftonline.com/{adconnection_id}/oauth2/token"
oauth2_token_issuer = "https://sts.windows.net/{adconnection_id}/"
federation_metadata_url = "https://login.microsoftonline.com/{adconnection_id}/federationmetadata/2007-06/federationmetadata.xml"
resource_url = "https://graph.windows.net"
コード例 #6
0
ファイル: __init__.py プロジェクト: spaceone/ucs-school
from univention.lib.i18n import Translation
from univention.management.console.log import MODULE
from univention.management.console.config import ucr
from univention.management.console.base import UMC_Error
from univention.management.console.modules.decorators import simple_response, sanitize
from univention.management.console.modules.sanitizers import StringSanitizer, DictSanitizer, DNSanitizer, ChoicesSanitizer
from univention.admin.uexceptions import base as uldapBaseException, noObject
import univention.admin.modules as udm_modules

from ucsschool.lib.schoolldap import SchoolBaseModule, LDAP_Connection, USER_READ, USER_WRITE, ADMIN_WRITE, SchoolSanitizer
from ucsschool.lib.models import SchoolClass, School, User, Student, Teacher, Staff, TeachersAndStaff, SchoolComputer, WindowsComputer, MacComputer, IPComputer, UCCComputer
from ucsschool.lib.models.utils import add_module_logger_to_schoollib

from univention.management.console.modules.schoolwizards.SchoolImport import SchoolImport

_ = Translation('ucs-school-umc-wizards').translate


# TODO: remove once this is implemented in uexceptions, see Bug #30088
def get_exception_msg(e):
	msg = getattr(e, 'message', '')
	if getattr(e, 'args', False):
		if e.args[0] != msg or len(e.args) != 1:
			for arg in e.args:
				msg += ' ' + arg
	return msg


USER_TYPES = {
	'student': Student,
	'teacher': Teacher,
コード例 #7
0
ファイル: util.py プロジェクト: bopopescu/smart-1
import tempfile
import subprocess
import threading
import univention.config_registry
from univention.config_registry.interfaces import RE_IFACE
import time
import re
import sys
import apt
import psutil
import csv

from univention.lib.i18n import Translation
from univention.management.console.log import MODULE

installer_i18n = Translation('installer',
                             localedir='/lib/univention-installer/locale')

if not '/lib/univention-installer/' in sys.path:
    sys.path.append('/lib/univention-installer/')
import package_list
import imp

ucr = univention.config_registry.ConfigRegistry()
ucr.load()

PATH_SYS_CLASS_NET = '/sys/class/net'
PATH_SETUP_SCRIPTS = '/usr/lib/univention-system-setup/scripts/'
PATH_JOIN_SCRIPT = '/usr/lib/univention-system-setup/scripts/setup-join.sh'
PATH_PROFILE = '/var/cache/univention-system-setup/profile'
LOG_FILE = '/var/log/univention/setup.log'
PATH_BROWSER_PID = '/var/cache/univention-system-setup/browser.pid'