def __init__(self, config=None, config_dir=None):
if config:<EOL><INDENT>if isinstance(config, dict):<EOL><INDENT>self.config = vaping.Config(data=config)<EOL><DEDENT>else:<EOL><INDENT>if not config.meta:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>self.config = config<EOL><DEDENT><DEDENT>elif config_dir:<EOL><INDENT>self.config = vaping.Config(read=config_dir)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>self.joins = []<EOL>self._logger = None<EOL>self.plugin_context = PluginContext(self.config)<EOL>vcfg = self.config.get('<STR_LIT>', None)<EOL>if not vcfg:<EOL><INDENT>vcfg = dict()<EOL><DEDENT>self.home_dir = vcfg.get('<STR_LIT>', None)<EOL>if not self.home_dir:<EOL><INDENT>self.home_dir = self.config.meta['<STR_LIT>']<EOL><DEDENT>if not os.path.exists(self.home_dir):<EOL><INDENT>raise ValueError("<STR_LIT>".format(self.home_dir))<EOL><DEDENT>if not os.access(self.home_dir, os.W_OK):<EOL><INDENT>raise ValueError("<STR_LIT>".format(self.home_dir))<EOL><DEDENT>os.chdir(self.home_dir)<EOL>plugins = self.config.get('<STR_LIT>', None)<EOL>if not plugins:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>plugin.instantiate(self.config['<STR_LIT>'], self.plugin_context)<EOL>for probe in self.config.get('<STR_LIT>', []):<EOL><INDENT>if plugin.exists(probe["<STR_LIT:name>"]):<EOL><INDENT>raise ValueError("<STR_LIT>".format(probe["<STR_LIT:name>"]))<EOL><DEDENT><DEDENT>pidname = vcfg.get('<STR_LIT>', '<STR_LIT>')<EOL>self.pidfile = pidfile.PidFile(pidname=pidname, piddir=self.home_dir)<EOL>
must either pass config as a dict or vaping.config.Config
or config_dir as a path to where the config dir is located