def set_conditional_wallpaper(city, time_level, walls_dir, file_format): weather, actual_city = get_current_weather(city) weather_code = get_weather_summary(weather) print('The retrieved weather for {} is {}'.format(actual_city, weather)) time_of_day = get_time_of_day(time_level) print('The current time of the day is {}'.format(time_of_day)) file_name = get_file_name(weather_code, time_of_day, walls_dir, file_format) desktop_env = Desktop.get_desktop_environment() Desktop.set_wallpaper(file_name, desktop_env)
def init(desktop): global main_window global draw_surface global window_x global window_y global width global height global init_done window_x = desktop[0] window_y = desktop[1] width = desktop[2] height = desktop[3] pygame.display.init pygame.font.init() main_window = pygame.display.set_mode((width, height), flags=pygame.NOFRAME) pygame.display.set_caption('RandoMame') desktop = Desktop.DesktopClass() desktop.set_position(os.getpid(), window_x, window_y, width, height) draw_surface = pygame.Surface((width, height)) print_text("RandoMame") init_done = True
def set_conditional_wallpaper(city, time_level, no_weather, walls_dir, file_format): if not no_weather: weather, actual_city = get_current_weather(city) weather_code = get_weather_summary(weather) print('The retrieved weather for {} is {}'.format(actual_city, weather)) else: weather_code = None time_of_day = get_time_of_day(time_level) print('The current time of the day is {}'.format(time_of_day)) file_name = get_file_name(weather_code, time_of_day, walls_dir, file_format) print('Changing wallpaper to {}'.format(file_name)) desktop_env = Desktop.get_desktop_environment() Desktop.set_wallpaper(file_name, desktop_env)
def set_conditional_wallpaper(city, time_level, no_weather, walls_dir, file_format, dst): if not no_weather: weather, actual_city = get_current_weather(city) weather_code = get_weather_summary(weather) print('The retrieved weather for {} is {}'.format(actual_city, weather)) else: weather_code = None time_of_day = get_time_of_day(level = time_level, dst = dst) print('The current time of the day is {}'.format(time_of_day)) file_name = get_file_name(weather_code, time_of_day, walls_dir, file_format) print('Changing wallpaper to {}'.format(file_name)) desktop_env = Desktop.get_desktop_environment() Desktop.set_wallpaper(file_name, desktop_env)
def main(): weather_json_url = r'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22' + city + '%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys' weather_json = json.loads(urlopen(weather_json_url).read().decode('utf-8')) weather = str(weather_json['query']['results']['channel']['item']['condition']['text']).lower() city_with_area=str(weather_json['query']['results']['channel']['location']['city']) + str(weather_json['query']['results']['channel']['location']['region']) print(weather) print(city_with_area) print(os.path.join(walls_dir, get_file_name(weather, time=use_time))) Desktop.set_wallpaper( os.path.join(walls_dir, get_file_name(weather, time=use_time)))
def main(): weather_json_url = r'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22' + city + '%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys' weather_json = json.loads(urlopen(weather_json_url).read().decode('utf-8')) weather = str(weather_json['query']['results']['channel']['item']['condition']['text']).lower() amanece = str(weather_json['query']['results']['channel']['astronomy']['sunrise']).lower() temp = int(weather_json['query']['results']['channel']['item']['condition']['temp']) temp = int((temp - 32) / 1.8) amanece = amanece.split(':') hora_ama = amanece[0] min_ama = amanece[1].split() min_ama = min_ama[0] amanecer = int(hora_ama)*60 + int(min_ama) atardece = str(weather_json['query']['results']['channel']['astronomy']['sunset']).lower() atardece = atardece.split(':') hora_ata = atardece[0] min_ata = atardece[1].split() min_ata = min_ata[0] atardecer = (int(hora_ata)+12)*60 + int(min_ata) city_with_area=str(weather_json['query']['results']['channel']['location']['city']) + str(weather_json['query']['results']['channel']['location']['region']) print(weather) print(city_with_area) print(os.path.join(walls_dir, get_file_name(weather, amanecer, atardecer, temp, time=use_time))) Desktop.set_wallpaper( os.path.join(walls_dir, get_file_name(weather, amanecer, atardecer, temp, time=use_time)))
def getDesktops(self, statusString): desktopList = [] #Finding the start and end of the monitor status monitorStart = statusString.find(self.name) #Finding end of monitor. This is hard because new monitors start with 'm' or 'M' but monacle layout is #also indicated with an m. This means we have to find monitors in some other way. #All montior names have a - in them which means we can look for those #monitorEnd = statusString.find("-", monitorStart + len(self.name)) #Get a substring of the monitor string monitorString = statusString[monitorStart:] #Find individual pieces monitorSplit = monitorString.split(":") #We now have an array with the current desktop layout on the monitor. #The first element is the name of the monitor itself which we don't want to use. The last two elements #are the layout and the start of the next monitor. Im not interested in those either monitorInfo = monitorSplit[1:-2] for mi in monitorInfo: dFocused = False if mi[0].lower() == "l": break #Get the status of the monitor #the first character is the status of the desktop desktopChar = mi[0] lc = desktopChar.lower() #finding the status of the desktop dStatus = util.dStatusDict[lc] if desktopChar.isupper(): dFocused = True #The rest of the string is the desktop name dName = mi[1:] #Adding the desktop to the list desktopList.append(Desktop.Desktop(dName, dStatus, dFocused)) return desktopList
def main(): input("Press ENTER to start...") start_time = time.clock() products = [ Laptop.Laptop(), Desktop.Desktop(), Monitor.Monitor(), Printer.Printer(), Mouse.Mouse(), Keyboard.Keyboard() ] for product in products: product.run() print("\n{0}s".format(time.clock() - start_time))
def apply_image(file_path): # Grabbing the current month curr_month = numbers_to_months() # If we are dealing with the default wallpapers if not file_path: logger.info("Alternate image location not detected") transform_images() logger.info("Applying [" + str(curr_month) + ".png" + "] as new wallpaper") print("Applying [" + str(curr_month) + ".png" + "] as new wallpaper") curr_month_file_path = (os.path.abspath("{}EditedWallpapers/{}.png".format(working_directory, str(curr_month)))) logging.info(curr_month_file_path) Desktop.set_wallpaper(curr_month_file_path, Desktop.get_desktop_environment()) # If we are dealing with a directory that the user has passed in else: logger.info("Alternate image location detected...attempting to apply wallpaper") Desktop.set_wallpaper(file_path + "/" + numbers_to_months(), Desktop.get_desktop_environment())
def on_website_selected(self): '''called when the website item is selected''' Desktop.open(EMESENE_WEBSITE)
sys.stderr.write('\nNot all required files were found.\n %s' % NAMING_RULES.format(file_format)) sys.exit(1) while True: try: weather_json_url = r'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22' + city + '%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys' weather_json = json.loads( urllib.request.urlopen(weather_json_url).read().decode('utf-8')) weather = str(weather_json['query']['results']['channel']['item'] ['condition']['text']).lower() print(weather) print(city) print(os.path.join(walls_dir, get_file_name(weather, time=use_time))) Desktop.set_wallpaper( os.path.join(walls_dir, get_file_name(weather, time=use_time))) except: pass time.sleep(wait_time)
def on_mail_click(self): if self.session.config.b_open_mail_in_desktop: webbrowser.open("mailto:") else: Desktop.open(self.session.get_mail_url())
def opendir(self): ''' open the directory that contains the file, once the transfer is finished ''' Desktop.open(os.path.dirname(self.transfer.completepath))
def open(self): ''' use desktop's open to open the file, once state is finished ''' Desktop.open(self.transfer.completepath)
sys.stderr.write(os.path.join(walls_dir, (i + file_format)) + '\n') return all_exist while True: try: weather_json_url = r'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22' + city + '%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys' weather_json = json.loads(urllib.request.urlopen(weather_json_url).read().decode('utf-8')) weather = str(weather_json['query']['results']['channel']['item']['condition']['text']).lower() if not check_if_all_files_exist(time=use_time, level=args.time): sys.stderr.write('\nNot all required files were found.\n %s' % NAMING_RULES.format(file_format)) sys.exit(1) print(os.path.join(walls_dir, get_file_name(weather, time=use_time))) Desktop.set_wallpaper(os.path.join(walls_dir, get_file_name(weather, time=use_time))) except: pass time.sleep(wait_time)
def on_website_selected(self): """called when the website item is selected""" Desktop.open(Info.EMESENE_WEBSITE)
def on_website_selected(self): '''called when the website item is selected''' Desktop.open(Info.EMESENE_WEBSITE)
def open_in_browser(self): Desktop.open(self._get_mail_url())
def open(self): ''' use desktop's open to open the file, once state is finished ''' Desktop.open(self.transfer.completepath)
from Computador import * from Desktop import * from Notebook import * tela = Desktop('Hp', 'Branco', 1.500, 100) print("----- Desktop -----") print(tela.getInformacoes()) tela.modelo = 'AOC' tela.cor = "Preto" tela.preco = 1.000 print('Dados atualizados: ') print(tela.getInformacoes()) tela.cadastrar() print('\n----- Notebook -----') note = Notebook('G3', 'Prata', 5.600, 500) print(note.getInformacoes()) note.modelo = 'Acer' note.cor = 'Prata' note.preco = 2.000 print('Dados atualizados: ') print(note.getInformacoes()) note.cadastrar()
def on_mail_click(self): if self.session.config.b_open_mail_in_desktop: webbrowser.open("mailto:") else: Desktop.open(self.session.get_mail_url())
def opendir(self): ''' open the directory that contains the file, once the transfer is finished ''' Desktop.open(os.path.dirname(self.transfer.completepath))
def start(): global window window_position = WindowPosition() if Config.desktop is not None: desktop_info = [ Config.desktop[0], Config.desktop[1], Config.desktop[2], Config.desktop[3] ] else: desktop_info = Desktop.get_desktop_size() position = window_position.get(Config.windows_quantity, 0, 0, desktop_info[2], desktop_info[3]) Display.init(desktop_info) if Config.mode == "music" or Config.smart_sound_timeout_sec > 0: Sound.init() machine_list, soft_list = XmlGetter.get() if machine_list is not None: print("MAME version: ", machine_list.attrib["build"]) print(len(machine_list), " unique machines") if soft_list is not None: print(len(soft_list), "software lists") Mode.init(machine_list, soft_list) desktop = DesktopClass() for index in range(Config.windows_quantity): window.append( Window.Window(desktop, index, desktop_info[0], desktop_info[1], position[index])) global sound_index while Display.wait_for_keyboard() is False: if Config.smart_sound_timeout_sec > 0: if Sound.get_silence_duration_sec( ) > Config.smart_sound_timeout_sec: sound_index = sound_index - 1 if sound_index == -1: sound_index = Config.windows_quantity - 1 for w in window: w.set_sound_index(sound_index) Sound.reset() is_alive = False for w in window: if w.is_alive() is True: is_alive = True break if is_alive is False: break if Config.end_duration is not None: if Config.record is None: time.sleep(float(Config.end_duration)) if Config.end_command is not None and window[0].get_start_command_launched( ) is True: print("Execute end command:", Config.end_command) os.system(Config.end_command) print("Shutdown remaining windows") shutdown() print("Stop sound recording thread") Sound.kill() print("Wait for remaining windows") for w in window: w.join() if Config.final_command is not None: print("Execute final command:", Config.final_command) os.system(Config.final_command) sys.exit(0)