# Path: myDevices/utils/config.py
# class Config:
#     def __init__(self, path):
#         self.mutex = RLock()
#         self.path = path
#         self.config = RawConfigParser()
#         self.config.optionxform = str
#         try:
#             with open(path) as fp:
#                 self.config.read_file(fp)
#         except:
#             pass
#             
#     def set(self, section, key, value):
#         with self.mutex:
#             try:
#                 self.config.set(section, key, value)
#             except NoSectionError:
#                 self.config.add_section(section)
#                 self.config.set(section, key, value)
#         self.save()
# 
#     def get(self, section, key, fallback=_UNSET):
#         return self.config.get(section, key, fallback=fallback)
# 
#     def getInt(self, section, key, fallback=_UNSET):
#         return self.config.getint(section, key, fallback=fallback)
#     
#     def remove(self, section, key):
#         with self.mutex:
#             result = self.config.remove_option(section, key)       
#         self.save()
# 
#     def save(self):
#         with self.mutex:
#             with open(self.path, 'w') as configfile:
#                 self.config.write(configfile)
# 
#     def sections(self):
#         return self.config.sections()
# 
# Path: myDevices/utils/logger.py
# def setInfo():
#     LOGGER.setLevel(INFO)
#     return
# 
# def info(message):
#     # if checkFlood(message):
#     #     return
#     LOGGER.info(message)
# 
# def error(message, *args, **kwargs):
#     if checkFlood(message):
#         return
#     LOGGER.error(message, *args, **kwargs)
# 
# Path: myDevices/plugins/manager.py
# PLUGIN_FOLDER = '/etc/myDevices/plugins'


import sys
from myDevices.utils.config import Config
from myDevices.utils.logger import setInfo, info, error
from myDevices.plugins.manager import PLUGIN_FOLDER

if __name__ == '__main__':
    # Run the code to disable a plugin in a script so it can be called via sudo
    setInfo()
    info(sys.argv)
    if len(sys.argv) != 3:
        error('Plugin not disabled, invalid arguments')
        sys.exit(1)
    filename = sys.argv[1]
    if filename.startswith(PLUGIN_FOLDER) and filename.endswith('.plugin'):
        section = sys.argv[2]

# Path: myDevices/utils/config.py
# class Config:
#     def __init__(self, path):
#         self.mutex = RLock()
#         self.path = path
#         self.config = RawConfigParser()
#         self.config.optionxform = str
#         try:
#             with open(path) as fp:
#                 self.config.read_file(fp)
#         except:
#             pass
#             
#     def set(self, section, key, value):
#         with self.mutex:
#             try:
#                 self.config.set(section, key, value)
#             except NoSectionError:
#                 self.config.add_section(section)
#                 self.config.set(section, key, value)
#         self.save()
# 
#     def get(self, section, key, fallback=_UNSET):
#         return self.config.get(section, key, fallback=fallback)
# 
#     def getInt(self, section, key, fallback=_UNSET):
#         return self.config.getint(section, key, fallback=fallback)
#     
#     def remove(self, section, key):
#         with self.mutex:
#             result = self.config.remove_option(section, key)       
#         self.save()
# 
#     def save(self):
#         with self.mutex:
#             with open(self.path, 'w') as configfile:
#                 self.config.write(configfile)
# 
#     def sections(self):
#         return self.config.sections()
# 
# Path: myDevices/utils/logger.py
# def setInfo():
#     LOGGER.setLevel(INFO)
#     return
# 
# def info(message):
#     # if checkFlood(message):
#     #     return
#     LOGGER.info(message)
# 
# def error(message, *args, **kwargs):
#     if checkFlood(message):
#         return
#     LOGGER.error(message, *args, **kwargs)
# 
# Path: myDevices/plugins/manager.py
# PLUGIN_FOLDER = '/etc/myDevices/plugins'


# Path: myDevices/plugins/disable.py
import sys
from myDevices.utils.config import Config
from myDevices.utils.logger import setInfo, info, error
from myDevices.plugins.manager import PLUGIN_FOLDER


if __name__ == '__main__':
    # Run the code to disable a plugin in a script so it can be called via sudo
    setInfo()
    info(sys.argv)
    if len(sys.argv) != 3:
        error('Plugin not disabled, invalid arguments')
        sys.exit(1)
    filename = sys.argv[1]
    if filename.startswith(PLUGIN_FOLDER) and filename.endswith('.plugin'):
        section = sys.argv[2]

        config = Config(filename)