mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-22 09:42:15 +03:00
added logout.py file for remove file
This commit is contained in:
parent
6294b6a824
commit
4d4dd2be61
2 changed files with 35 additions and 4 deletions
34
src/plugins/browser-chrome/logout.py
Normal file
34
src/plugins/browser-chrome/logout.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Author:Ebru ARSLAN <ebru.arslan@pardus.org.tr>
|
||||||
|
|
||||||
|
from base.plugin.abstract_plugin import AbstractPlugin
|
||||||
|
|
||||||
|
|
||||||
|
class Logout(AbstractPlugin):
|
||||||
|
def __init__(self, context):
|
||||||
|
super(Logout, self).__init__()
|
||||||
|
self.context = context
|
||||||
|
self.logger = self.get_logger()
|
||||||
|
self.local_settings_path_suffix = 'policies/managed/'
|
||||||
|
self.local_settings_path = '/etc/opt/chrome/'
|
||||||
|
self.local_settings_proxy_profile = '/etc/profile.d/'
|
||||||
|
self.local_settings_proxy_file = 'liderahenk_chrome_proxy.sh'
|
||||||
|
self.logger.info('Parameters were initialized.')
|
||||||
|
self.user_js_file = "browser_chrome_preferences_{0}.json"
|
||||||
|
|
||||||
|
self.logger.debug('Parameters were initialized.')
|
||||||
|
|
||||||
|
def handle_logout_mode(self):
|
||||||
|
username = self.get_username()
|
||||||
|
profil_full_path = self.local_settings_path+self.local_settings_path_suffix+self.user_js_file.format(username)
|
||||||
|
profil_proxy_path = self.local_settings_proxy_profile+self.local_settings_proxy_file
|
||||||
|
if self.is_exist(profil_full_path):
|
||||||
|
self.delete_file(profil_full_path)
|
||||||
|
if self.is_exist(profil_proxy_path):
|
||||||
|
self.delete_file(profil_proxy_path)
|
||||||
|
|
||||||
|
|
||||||
|
def handle_mode(context):
|
||||||
|
logout = Logout(context)
|
||||||
|
logout.handle_logout_mode()
|
|
@ -75,11 +75,10 @@ class BrowserChrome(AbstractPlugin):
|
||||||
elif type(pref["value"]).__name__ == "int":
|
elif type(pref["value"]).__name__ == "int":
|
||||||
line = '"'+pref["preferenceName"]+'":' + str(pref["value"])+',\n'
|
line = '"'+pref["preferenceName"]+'":' + str(pref["value"])+',\n'
|
||||||
else:
|
else:
|
||||||
line = '"'+pref["preferenceName"]+'":' + str(pref["value"])+'",\n'
|
line = '"'+pref["preferenceName"]+'":"' + str(pref["value"])+'",\n'
|
||||||
content += line
|
content += line
|
||||||
|
|
||||||
content += "\n}"
|
content += "\n}"
|
||||||
self.logger.debug(content)
|
|
||||||
self.write_file(file_full_path, content)
|
self.write_file(file_full_path, content)
|
||||||
|
|
||||||
self.logger.debug('User chrome preferences were wrote successfully')
|
self.logger.debug('User chrome preferences were wrote successfully')
|
||||||
|
@ -117,5 +116,3 @@ class BrowserChrome(AbstractPlugin):
|
||||||
def handle_policy(profile_data, context):
|
def handle_policy(profile_data, context):
|
||||||
browser = BrowserChrome(profile_data, context)
|
browser = BrowserChrome(profile_data, context)
|
||||||
browser.handle_policy()
|
browser.handle_policy()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue