本文整理汇总了Python中univention.management.console.log.MODULE类的典型用法代码示例。如果您正苦于以下问题:Python MODULE类的具体用法?Python MODULE怎么用?Python MODULE使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MODULE类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _thread
def _thread(request):
message = None
success = True
result = []
partition = request.options['partitionDevice']
unicode_user = request.options['user']
user = unicode_user.encode('utf-8')
size_soft = request.options['sizeLimitSoft']
size_hard = request.options['sizeLimitHard']
file_soft = request.options['fileLimitSoft']
file_hard = request.options['fileLimitHard']
self._check_error(request, partition)
failed = tools.setquota(partition, user, tools.byte2block(size_soft),
tools.byte2block(size_hard),
file_soft, file_hard)
if failed:
MODULE.error('Failed to modify quota settings for user %s '
'on partition %s' % (user, partition))
message = _('Failed to modify quota settings for user %s on '
'partition %s') % (user, partition)
request.status = MODULE_ERR
self.finished(request.id, None, message)
message = _('Successfully set quota settings')
return {'result': result, 'message': message, 'success': success}
开发者ID:B-Rich,项目名称:smart,代码行数:25,代码来源:user.py
示例2: install
def install(self, package_manager, component_manager, add_component=True):
try:
# remove all existing component versions
for iapp in self.versions:
# dont remove yourself (if already added)
if iapp is not self:
component_manager.remove_app(iapp)
# add the new repository component for the app
ucr.load()
is_master = ucr.get('server/role') in ('domaincontroller_master', 'domaincontroller_backup') # packages need to be installed on backup AND master systems
to_install = self.get('defaultpackages')
if is_master and self.get('defaultpackagesmaster'):
to_install.extend(self.get('defaultpackagesmaster'))
if add_component:
component_manager.put_app(self)
package_manager.update()
# install + dist_upgrade
package_manager.log('\n== INSTALLING %s AT %s ==\n' % (self.name, datetime.now()))
package_manager.commit(install=to_install, dist_upgrade=True)
# successful installation
status = 200
except:
MODULE.warn(traceback.format_exc())
status = 500
self._send_information('install', status)
return status == 200
开发者ID:B-Rich,项目名称:smart,代码行数:30,代码来源:app_center.py
示例3: list_jobs
def list_jobs(self,request):
""" returns list of jobs for one printer. """
# ----------- DEBUG -----------------
MODULE.info("printers/jobs/query invoked with:")
pp = pprint.PrettyPrinter(indent=4)
st = pp.pformat(request.options).split("\n")
for s in st:
MODULE.info(" << %s" % s)
# -----------------------------------
printer = request.options.get('printer','')
result = self._job_list(printer)
# ---------- DEBUG --------------
MODULE.info("printers/jobs/query returns:")
pp = pprint.PrettyPrinter(indent=4)
st = ''
if len(result) > 5:
tmp = result[0:5]
MODULE.info(" >> %d entries, first 5 are:" % len(result))
st = pp.pformat(tmp).split("\n")
else:
st = pp.pformat(result).split("\n")
for s in st:
MODULE.info(" >> %s" % s)
# --------------------------------
self.finished(request.id,result)
开发者ID:B-Rich,项目名称:smart,代码行数:29,代码来源:__init__.py
示例4: getUserAndMailbox
def getUserAndMailbox(userdn):
co, lo, pos = getCoLoPos()
server = univention.admin.modules.get("asterisk/server")
univention.admin.modules.init(lo, pos, server)
objs = server.lookup(co, lo, None)
checkServers = []
for obj in objs:
checkServers.append({
"label": obj["commonName"],
})
MODULE.error('User: server: %s' % len(checkServers))
if len(checkServers) >0 :
co, lo = getCoLo()
user = getUser(co, lo, userdn)
mailbox = user.get("mailbox")
if mailbox:
mailbox = getMailbox(co, lo, mailbox)
return user, mailbox
elif len(checkServers) == 0 :
MODULE.error('Fehler gefunden!')
mailbox = "KeinServer"
user = "KeinServer"
return user, mailbox
开发者ID:decoit,项目名称:asterisk4ucs,代码行数:29,代码来源:__init__.py
示例5: partitions_info
def partitions_info(self, request):
result = {}
message = None
try:
fs = fstab.File()
mt = mtab.File()
except IOError as error:
MODULE.error("Could not open %s" % error.filename)
message = _("Could not open %s") % error.filename
request.status = MODULE_ERR
else:
partition = fs.find(spec=request.options["partitionDevice"])
if partition:
mounted_partition = mt.get(partition.spec)
if mounted_partition:
result["mountPoint"] = mounted_partition.mount_point
result["filesystem"] = mounted_partition.type
result["options"] = mounted_partition.options
request.status = SUCCESS
else:
request.status = MODULE_ERR
message = _("This partition is currently not mounted")
else:
request.status = MODULE_ERR
message = _("No partition found")
self.finished(request.id, result, message)
开发者ID:kielfriedt,项目名称:smart,代码行数:26,代码来源:partition.py
示例6: partitions_query
def partitions_query(self, request):
result = []
message = None
try:
fs = fstab.File()
mt = mtab.File()
except IOError as error:
MODULE.error("Could not open %s" % error.filename)
message = _("Could not open %s") % error.filename
request.status = MODULE_ERR
else:
partitions = fs.get(["xfs", "ext3", "ext2"], False) # TODO: ext4?
for partition in partitions:
list_entry = {}
list_entry["partitionDevice"] = partition.spec
list_entry["mountPoint"] = partition.mount_point
list_entry["partitionSize"] = None
list_entry["freeSpace"] = None
list_entry["inUse"] = None
mounted_partition = mt.get(partition.spec)
if mounted_partition:
partition_info = df.DeviceInfo(partition.mount_point)
list_entry["partitionSize"] = tools.block2byte(partition_info.size(), "GB", 1)
list_entry["freeSpace"] = tools.block2byte(partition_info.free(), "GB", 1)
if "usrquota" in mounted_partition.options:
list_entry["inUse"] = True
else:
list_entry["inUse"] = False
result.append(list_entry)
request.status = SUCCESS
self.finished(request.id, result, message)
开发者ID:kielfriedt,项目名称:smart,代码行数:31,代码来源:partition.py
示例7: save
def save( self, request ):
"""Saves the UCS Active Directory Connector configuration
options:
LDAP_Host: hostname of the AD server
LDAP_Base: LDAP base of the AD server
LDAP_BindDN: LDAP DN to use for authentication
KerberosDomain: kerberos domain
PollSleep: time in seconds between polls
RetryRejected: how many time to retry a synchronisation
MappingSyncMode: synchronisation mode
MappingGroupLanguage: language of the AD server
return: { 'success' : (True|False), 'message' : <details> }
"""
self.required_options( request, *map( lambda x: x[ 0 ], Instance.OPTION_MAPPING ) )
self.guessed_baseDN = None
try:
fn = '%s/.htaccess' % DIR_WEB_AD
fd = open( fn, 'w' )
fd.write( 'require user %s\n' % self._username )
fd.close()
os.chmod( fn, 0644 )
os.chown( fn, 0, 0 )
except Exception, e:
message = _( 'An error occured while saving .htaccess (filename=%(fn)s ; exception=%(exception)s)') % { 'fn': fn, 'exception': e.__class__.__name__ }
MODULE.process( 'An error occured while saving .htaccess (filename=%(fn)s ; exception=%(exception)s)' % { 'fn': fn, 'exception': e.__class__.__name__ } )
self.finished( request.id, { 'success' : False, 'message' : message } )
return
开发者ID:B-Rich,项目名称:smart,代码行数:31,代码来源:__init__.py
示例8: _thread
def _thread(request, obj, username, password):
# acquire the lock until the scripts have been executed
self._finishedResult = False
obj._finishedLock.acquire()
try:
self._progressParser.reset()
# write the profile file and run setup scripts
util.pre_save(values, orgValues)
# on unjoined DC master the nameserver must be set to the external nameserver
if newrole == 'domaincontroller_master' and not orgValues.get('joined'):
for i in range(1,4):
# overwrite these values only if they are set, because the UMC module
# will save only changed values
if values.get( 'dns/forwarder%d'%i ):
values[ 'nameserver%d'%i ] = values.get( 'dns/forwarder%d'%i )
MODULE.info('saving profile values')
util.write_profile(values)
# unjoined DC master (that is not being converted to a basesystem) -> run the join script
MODULE.info('runnning system setup join script')
util.run_joinscript( self._progressParser, username, password )
# done :)
self._finishedResult = True
# we should do a cleanup now
self._cleanup_required = True
return True
finally:
obj._finishedLock.release()
开发者ID:B-Rich,项目名称:smart,代码行数:34,代码来源:__init__.py
示例9: request
def request( self, command, **kwargs ):
MODULE.info( 'Sending request %s to UVMM daemon ...' % command )
try:
request = eval( 'protocol.Request_%s()' % command )
except NameError, AttributeError:
MODULE.error( 'Failed to create request %s' % command )
raise UVMM_Error( _( 'The given UVMM command is not known' ) )
开发者ID:B-Rich,项目名称:smart,代码行数:7,代码来源:uvmmd.py
示例10: _fetch_file
def _fetch_file(self, key, url):
try:
# open the license file
fp = util.urlopen(url)
self._options[key] = ''.join(fp.readlines()).strip()
except (urllib2.HTTPError, urllib2.URLError) as e:
MODULE.warn('No information for %s available (%s): %s' % (key, e, url))
开发者ID:B-Rich,项目名称:smart,代码行数:7,代码来源:app_center.py
示例11: _thread
def _thread( request ):
result = []
for ldap_dn in request.options:
if request.flavor == 'users/self':
ldap_dn = self._user_dn
module = get_module( request.flavor, ldap_dn )
if module is None:
MODULE.process( 'A module for the LDAP DN %s could not be found' % ldap_dn )
continue
obj = module.get( ldap_dn )
if obj:
props = obj.info
for passwd in module.password_properties:
if passwd in props:
del props[ passwd ]
props[ '$dn$' ] = obj.dn
props[ '$options$' ] = {}
for opt in module.get_options( udm_object = obj ):
props[ '$options$' ][ opt[ 'id' ] ] = opt[ 'value' ]
props[ '$policies$' ] = {}
for policy in obj.policies:
pol_mod = get_module( None, policy )
if pol_mod and pol_mod.name:
props[ '$policies$' ][ pol_mod.name ] = policy
props[ '$labelObjectType$' ] = module.title;
result.append( props )
else:
MODULE.process( 'The LDAP object for the LDAP DN %s could not be found' % ldap_dn )
return result
开发者ID:B-Rich,项目名称:smart,代码行数:29,代码来源:__init__.py
示例12: colors
def colors( self, request ):
"""Returns a list of all existing colors."""
MODULE.info( 'MODULEID.colors: options: %s' % str( request.options ) )
allColors = set(map(lambda x: x['color'], Instance.entries))
allColors = map(lambda x: { 'id': x, 'label': x }, allColors)
allColors.append({ 'id': 'None', 'label': _('All colors') })
MODULE.info( 'MODULEID.colors: result: %s' % str( allColors ) )
self.finished(request.id, allColors)
开发者ID:B-Rich,项目名称:smart,代码行数:8,代码来源:__init__.py
示例13: uninstall_dry_run
def uninstall_dry_run(self, package_manager):
MODULE.info('Invoke uninstall_dry_run')
package_manager.reopen_cache()
to_uninstall = package_manager.get_packages(self.get('defaultpackages'))
for package in to_uninstall:
package.mark_delete()
packages = [pkg.name for pkg in package_manager.packages() if pkg.is_auto_removable]
package_manager.reopen_cache()
return packages
开发者ID:B-Rich,项目名称:smart,代码行数:9,代码来源:app_center.py
示例14: getServer
def getServer(dn):
co, lo, pos = getCoLoPos()
server = univention.admin.modules.get("asterisk/server")
univention.admin.modules.init(lo, pos, server)
obj = server.object(co, lo, None, dn)
MODULE.error("server dn: %s" % dn)
obj.open()
return obj
开发者ID:decoit,项目名称:asterisk4ucs,代码行数:9,代码来源:__init__.py
示例15: _thread_finish_success
def _thread_finish_success( self, thread, result, request ):
"""This method is invoked when a threaded request function is
finished. The result is send back to the client. If the result
is an instance of BaseException an error is returned."""
if self._check_thread_error( thread, result, request ):
return
success, data = result
MODULE.info( 'Got result from UVMMd: success: %s, data: %s' % ( success, data ) )
self.finished( request.id, { 'success' : success, 'data' : data } )
开发者ID:B-Rich,项目名称:smart,代码行数:10,代码来源:__init__.py
示例16: _send_return
def _send_return( thread, result, request ):
import traceback
if not isinstance( result, BaseException ):
MODULE.info( 'sending mail: completed successfully' )
self.finished( request.id, True )
else:
msg = '%s\n%s: %s\n' % ( ''.join( traceback.format_tb( thread.exc_info[ 2 ] ) ), thread.exc_info[ 0 ].__name__, str( thread.exc_info[ 1 ] ) )
MODULE.process( 'sending mail:An internal error occurred: %s' % msg )
self.finished( request.id, False, msg, False )
开发者ID:B-Rich,项目名称:smart,代码行数:10,代码来源:__init__.py
示例17: process_button
def process_button(self):
# if self._first_attempt_button:
# self._first_attempt_button = False
# raise UMC_Error(_('First try failed. Try again.'))
MODULE.process('Generating new secret...')
newkey_path = "/etc/openvpn/sitetosite.newkey"
os.popen("openvpn --genkey --secret %s" % newkey_path)
with open(newkey_path, 'r') as newkey_file:
newkey=newkey_file.read().replace('\n', '<br />')
return newkey
开发者ID:bytemine,项目名称:univention-openvpn,代码行数:10,代码来源:__init__.py
示例18: _check_thread_error
def _check_thread_error( self, thread, result, request ):
"""Checks if the thread returned an exception. In that case in
error response is send and the function returns True. Otherwise
False is returned."""
if not isinstance( result, BaseException ):
return False
msg = '%s\n%s: %s\n' % ( ''.join( traceback.format_tb( thread.exc_info[ 2 ] ) ), thread.exc_info[ 0 ].__name__, str( thread.exc_info[ 1 ] ) )
MODULE.process( 'An internal error occurred: %s' % msg )
self.finished( request.id, None, msg, False )
return True
开发者ID:B-Rich,项目名称:smart,代码行数:11,代码来源:__init__.py
示例19: calculateFractions
def calculateFractions( self ):
MODULE.info( 'Calculating maximum value for fractions ...' )
for category in filter( lambda x: os.path.isdir( os.path.join( PATH_SETUP_SCRIPTS, x ) ), os.listdir( PATH_SETUP_SCRIPTS ) ):
cat_path = os.path.join( PATH_SETUP_SCRIPTS, category )
for script in filter( lambda x: os.path.isfile( os.path.join( cat_path, x ) ), os.listdir( cat_path ) ):
name = '%s/%s' % ( category, script )
if not name in self.fractions:
self.fractions[ name ] = 1
self.current.max = sum( self.fractions.values() )
MODULE.info( 'Calculated a maximum value of %d' % self.current.max )
开发者ID:B-Rich,项目名称:smart,代码行数:11,代码来源:util.py
示例20: _thread_finished
def _thread_finished(self, thread, thread_result, request):
if not isinstance(thread_result, BaseException):
request.status = SUCCESS
self.finished(request.id, {'objects': thread_result['result'],
'success': thread_result['success']},
thread_result['message'])
else:
message = str(thread_result) + '\n' + '\n'.join(thread.trace)
MODULE.error('An internal error occurred: %s' % message)
request.status = MODULE_ERR
self.finished(request.id, None, message)
开发者ID:B-Rich,项目名称:smart,代码行数:11,代码来源:user.py
注:本文中的univention.management.console.log.MODULE类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论