def __init__(self): super().__init__( command_prefix=self._get_prefix, help_command=None, description='Zawsze pomocny Somsiad', case_insensitive=True, intents=discord.Intents.all(), ) self.components_manager = DiscordComponents(self) if not os.path.exists(self.storage_dir_path): os.makedirs(self.storage_dir_path) if not os.path.exists(self.cache_dir_path): os.makedirs(self.cache_dir_path) self.prefix_safe_aliases = () self.prefixes = {} self.diagnostics_on = False self.commands_being_processed = defaultdict(int) self.ready_datetime = None self.session = None self.ch_client = None self.google_client = ( GoogleClient(configuration['google_key'], configuration['google_custom_search_engine_id'], self.loop) if configuration.get('google_key') is not None and configuration.get('google_custom_search_engine_id') is not None else None ) self.youtube_client = ( YouTubeClient(configuration['google_key'], self.loop) if configuration.get('google_key') is not None else None ) self.system_channel = None self.public_channel = None
def init(**kwargs): """Initialise PyOP2: select the backend and potentially other configuration options. :arg backend: Set the hardware-specific backend. Current choices are ``"sequential"``, ``"openmp"``, ``"opencl"``, ``"cuda"``. :arg debug: The level of debugging output. :arg comm: The MPI communicator to use for parallel communication, defaults to `MPI_COMM_WORLD` :arg log_level: The log level. Options: DEBUG, INFO, WARNING, ERROR, CRITICAL :arg opt_level: The default optimization level in COFFEE. Options: O0, O1, O2, O3, Ofast. For more information about these levels, refer to ``coffee_init``'s documentation. The default value is O0. For debugging purposes, `init` accepts all keyword arguments accepted by the PyOP2 :class:`Configuration` object, see :meth:`Configuration.__init__` for details of further accepted options. .. note:: Calling ``init`` again with a different backend raises an exception. Changing the backend is not possible. Calling ``init`` again with the same backend or not specifying a backend will update the configuration. Calling ``init`` after ``exit`` has been called is an error and will raise an exception. """ backend = backends.get_backend() if backend == 'pyop2.finalised': raise RuntimeError("Calling init() after exit() is illegal.") if backend != 'pyop2.void' and \ "backend" in kwargs and \ backend != "pyop2.%s" % kwargs["backend"]: raise RuntimeError("Calling init() for a different backend is illegal.") configuration.reconfigure(**kwargs) set_log_level(configuration['log_level']) if backend == 'pyop2.void': try: backends.set_backend(configuration["backend"]) except: configuration.reset() raise backends._BackendSelector._backend._setup() coffee_init(compiler=configuration['compiler'], isa=configuration['simd_isa'], optlevel=configuration.get('opt_level', O0))
def setup(bot: commands.Bot): if configuration.get('goodreads_key') is not None: bot.add_cog(Goodreads(bot))
def setup(bot: commands.Bot): if configuration.get('wolfram_alpha_app_id') is not None: bot.add_cog(WolframAlpha(bot))
def setup(bot: commands.Bot): if configuration.get('tmdb_key') is not None: bot.add_cog(TMDb(bot))
env = agent.wrap_env(env) env.seed(seed) for task in tasks: agent.reset_state() if task is not None: env.unwrapped.set_next_task(task) obs = env.reset() if task is None: print(env.unwrapped.state) done = False while not done: obs, _, done, _ = env.step(agent.act(obs)) if __name__ == '__main__': deep_rl.configure(**configuration) parser = argparse.ArgumentParser() parser.add_argument('name', type=str, help='Experiment name') args = parser.parse_args() name = args.name package_name = 'experiments.%s' % name.replace('-', '_') package = __import__(package_name, fromlist=['']) screen_size = package.default_args()['env_kwargs'].get('screen_size', None) videos_path = os.path.join(configuration.get('videos_path'), name) os.makedirs(videos_path, exist_ok=True) agent = make_agent(name) record_videos(agent, videos_path, screen_size)
def setup(bot: Somsiad): if configuration.get('twitter_bearer_token') is not None: bot.add_cog(Twitter(bot))
d['light'] = poller.parameter_value(MI_LIGHT) d['conductivity'] = poller.parameter_value(MI_CONDUCTIVITY) d['battery'] = poller.parameter_value(MI_BATTERY) except BluetoothBackendException as e: d['data'] = 'no data' return d def map_sensor_data_entity(sensor_data, sensor_name): if not 'data' in sensor_data: p = SensorData(temperature=sensor_data['temperature'], moisture=sensor_data['moisture'], fertility=sensor_data['conductivity'], light=sensor_data['light'], battery=sensor_data['battery'], sensor_name=sensor_name) return p return None if __name__ == "__main__": sensors = configuration.get("sensors") for sensor in sensors: bluetooth_mac_address = sensor.get('bluetooth_mac_address') sensor_name = sensor.get('name') poller = MiFloraPoller(bluetooth_mac_address, GatttoolBackend) sensordata_raw = get_miflora_data(poller) sensordata_entity = map_sensor_data_entity(sensor_data=sensordata_raw, sensor_name=sensor_name) persist(sensordata_entity)
from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from configuration import configuration db_connection = configuration.get('database') username = db_connection.get('username') password = db_connection.get('password') host = db_connection.get('host') db_name = db_connection.get('db_name') SQLALCHEMY_DATABASE_URI = "mysql+pymysql://{}:{}@{}:3306/{}".format( username, password, host, db_name) engine = create_engine(SQLALCHEMY_DATABASE_URI) Session = sessionmaker(bind=engine) def persist(entity): session = Session() session.add(entity) session.commit() session.close() if __name__ == "__main__": print(SQLALCHEMY_DATABASE_URI)