def __init__(self): super(HiveMindSkill, self).__init__(name='HiveMindSkill') # skill behaviour if "priority" not in self.settings: self.settings["priority"] = 50 if "timeout" not in self.settings: self.settings["timeout"] = 15 if "port" not in self.settings: self.settings["port"] = DEFAULT_PORT if "listen" not in self.settings: self.settings["listen"] = True if "ssl" not in self.settings: self.settings["ssl"] = True if "access_key" not in self.settings: self.settings["access_key"] = "RESISTENCEisFUTILE" if "crypto_key" not in self.settings: self.settings["crypto_key"] = "resistanceISfutile" if "client_name" not in self.settings: self.settings["client_name"] = "HiveMindSkill" if "add_key" not in self.settings: self.settings["add_key"] = False if "revoke_key" not in self.settings: self.settings["revoke_key"] = False for k in CONFIGURATION: if k not in self.settings: self.settings[k] = CONFIGURATION[k] self._old_settings = dict(self.settings) # events self.settings_change_callback = self._on_web_settings_change self.namespace = "jarbas.hivemind" self.skill_name = camel_case_split(self.__class__.__name__)
def on_error(e): """Speak and log the error.""" # Convert "MyFancySkill" to "My Fancy Skill" for speaking handler_name = camel_case_split(self.name) msg_data = {'skill': handler_name} msg = dialog.get('skill.error', self.lang, msg_data) self.speak(msg) LOG.exception(msg) # append exception information in message skill_data['exception'] = repr(e)
def __init__(self): super(HiveMindSkill, self).__init__(name='HiveMindSkill') # skill behaviour if "priority" not in self.settings: self.settings["priority"] = 50 if "timeout" not in self.settings: self.settings["timeout"] = 15 for k in CONFIGURATION: if k not in self.settings: self.settings[k] = CONFIGURATION[k] self._old_settings = dict(self.settings) # events self.settings_change_callback = self._on_web_settings_change self.namespace = "jarbas.hivemind" self.skill_name = camel_case_split(self.__class__.__name__)
def wrapper(message): skill_data = {'name': get_handler_name(handler)} stopwatch = Stopwatch() try: message = unmunge_message(message, self.skill_id) # Indicate that the skill handler is starting if handler_info: # Indicate that the skill handler is starting if requested msg_type = handler_info + '.start' self.bus.emit(message.reply(msg_type, skill_data)) if once: # Remove registered one-time handler before invoking, # allowing them to re-schedule themselves. self.remove_event(name) with stopwatch: if len(signature(handler).parameters) == 0: handler() else: handler(message) self.settings.store() # Store settings if they've changed except Exception as e: # Convert "MyFancySkill" to "My Fancy Skill" for speaking handler_name = camel_case_split(self.name) msg_data = {'skill': handler_name} msg = dialog.get('skill.error', self.lang, msg_data) self.speak(msg) LOG.exception(msg) # append exception information in message skill_data['exception'] = repr(e) finally: # Indicate that the skill handler has completed if handler_info: msg_type = handler_info + '.complete' self.bus.emit(message.reply(msg_type, skill_data)) # Send timing metrics context = message.context if context and 'ident' in context: report_timing(context['ident'], 'skill_handler', stopwatch, {'handler': handler.__name__})
def __init__(self): super(MySkill, self).__init__(name='MySkill') # skill settings defaults if "intercept_allowed" not in self.settings: self.settings["intercept_allowed"] = False if "priority" not in self.settings: self.settings["priority"] = 50 if "timeout" not in self.settings: self.settings["timeout"] = 15 # state trackers self._converse_keepalive = None self.waiting = False self.success = False self._old_settings = dict(self.settings) # events self.settings_change_callback = self._on_web_settings_change self.namespace = self.__class__.__name__.lower() self.skill_name = camel_case_split(self.__class__.__name__)
def test_camel_case_split(self): """Check that camel case string is split properly.""" self.assertEqual(camel_case_split('MyCoolSkill'), 'My Cool Skill') self.assertEqual(camel_case_split('MyCOOLSkill'), 'My COOL Skill')
def display_name(name): """ Splits camelcase and removes leading/trailing Skill. """ name = re.sub(r'(^[Ss]kill|[Ss]kill$)', '', name) return camel_case_split(name)
def get_display_name(skill_name: str): """Splits camelcase and removes leading/trailing "skill".""" skill_name = re.sub(r'(^[Ss]kill|[Ss]kill$)', '', skill_name) return camel_case_split(skill_name)
def __init__(self): super(WallpapersSkill, self).__init__(name='Wallpapers') # skill settings defaults if "auto_detect" not in self.settings: self.settings["auto_detect"] = True if "desktop_env" not in self.settings: self.settings["desktop_env"] = get_desktop_environment() if "rotate_wallpaper" not in self.settings: self.settings["rotate_wallpaper"] = True if "change_mins" not in self.settings: self.settings["change_mins"] = 30 # imaage sources if "unsplash" not in self.settings: self.settings["unsplash"] = False if "wpcraft" not in self.settings: self.settings["wpcraft"] = True subs = [ '/r/EarthPorn', '/r/BotanicalPorn', '/r/WaterPorn', '/r/SeaPorn', '/r/SkyPorn', '/r/FirePorn', '/r/DesertPorn', '/r/WinterPorn', '/r/AutumnPorn', '/r/WeatherPorn', '/r/GeologyPorn', '/r/SpacePorn', '/r/BeachPorn', '/r/MushroomPorn', '/r/SpringPorn', '/r/SummerPorn', '/r/LavaPorn', '/r/LakePorn', '/r/CityPorn', '/r/VillagePorn', '/r/RuralPorn', '/r/ArchitecturePorn', '/r/HousePorn', '/r/CabinPorn', '/r/ChurchPorn', '/r/AbandonedPorn', '/r/CemeteryPorn', '/r/InfrastructurePorn', '/r/MachinePorn', '/r/CarPorn', '/r/F1Porn', '/r/MotorcyclePorn', '/r/MilitaryPorn', '/r/GunPorn', '/r/KnifePorn', '/r/BoatPorn', '/r/RidesPorn', '/r/DestructionPorn', '/r/ThingsCutInHalfPorn', '/r/StarshipPorn', '/r/ToolPorn', '/r/TechnologyPorn', '/r/BridgePorn', '/r/PolicePorn', '/r/SteamPorn', '/r/RetailPorn', '/r/SpaceFlightPorn', '/r/roadporn', '/r/drydockporn', '/r/AnimalPorn', '/r/HumanPorn', '/r/EarthlingPorn', '/r/AdrenalinePorn', '/r/ClimbingPorn', '/r/SportsPorn', '/r/AgriculturePorn', '/r/TeaPorn', '/r/BonsaiPorn', '/r/FoodPorn', '/r/CulinaryPorn', '/r/DessertPorn', '/r/DesignPorn', '/r/RoomPorn', '/r/AlbumArtPorn', '/r/MetalPorn', '/r/MoviePosterPorn', '/r/TelevisionPosterPorn', '/r/ComicBookPorn', '/r/StreetArtPorn', '/r/AdPorn', '/r/ArtPorn', '/r/FractalPorn', '/r/InstrumentPorn', '/r/ExposurePorn', '/r/MacroPorn', '/r/MicroPorn', '/r/GeekPorn', '/r/MTGPorn', '/r/GamerPorn', '/r/PowerWashingPorn', '/r/AerialPorn', '/r/OrganizationPorn', '/r/FashionPorn', '/r/AVPorn', '/r/ApocalypsePorn', '/r/InfraredPorn', '/r/ViewPorn', '/r/HellscapePorn', '/r/sculptureporn', '/r/HistoryPorn', '/r/UniformPorn', '/r/BookPorn', '/r/NewsPorn', '/r/QuotesPorn', '/r/FuturePorn', '/r/FossilPorn', '/r/MegalithPorn', '/r/ArtefactPorn', '/r/AmateurEarthPorn', '/r/AmateurPhotography', '/r/ArtistOfTheDay', '/r/BackgroundArt', '/r/Conservation', '/r/EarthPornVids', '/r/EyeCandy', '/r/FWEPP', '/r/ImaginaryLandscapes', '/r/ImaginaryWildlands', '/r/IncredibleIndia', '/r/ITookAPicture', '/r/JoshuaTree', '/r/NationalGeographic', '/r/Nature', '/r/NatureGifs', '/r/NaturePics', '/r/NotSafeForNature', '/r/NZPhotos', '/r/remoteplaces', '/r/Schweiz', '/r/SpecArt', '/r/wallpapers', "/r/InterstellarArt" ] self.subs = [s.split("/")[-1].strip() for s in subs] self.wpcats = [ '3d', 'abstract', 'animals', 'anime', "art", "black", "cars", 'city', 'dark', 'fantasy', 'flowers', 'food', 'holidays', 'love', 'macro', 'minimalism', 'motorcycles', 'music', 'nature', 'other', 'smilies', 'space', 'sport', 'hi-tech', 'textures', 'vector', 'words', '60_favorites' ] for c in self.subs: if c not in self.settings: self.settings[c] = True for c in self.wpcats: if c not in self.settings: self.settings[c] = True # state trackers self.pic_idx = 0 self.picture_list = [] self.translate_cache = {} self._old_settings = dict(self.settings) # events self.settings_change_callback = self._on_web_settings_change self.namespace = self.__class__.__name__.lower() self.skill_name = camel_case_split(self.__class__.__name__)