def update(): scriptpage = Page(site, "User:Legoktm/BOTFAQ/Code/redir.py") text = file('redir.py').read() text = '<source lang="python">\n' + text + '</sou' + 'rce>' # Split to confuse MW parser if scriptpage.get() != text: summary = 'Updating source' scriptpage.put(text, summary)
def bot_control(self,site): import urllib from wikipedia import Error, Page wt_username = urllib.quote(config.usernames[self.name][site.lang].encode('utf-8')) wt_namespace = urllib.quote(self.namespaces[2][site.lang].encode('utf-8')) wt_user_run = unicode(wt_namespace) + u':' + unicode(wt_username) + u'/Run' wt_page = Page(site, wt_user_run) wt_user_run_text = wt_page.get(get_redirect = True) wt_namespace = urllib.quote(self.namespaces[4][site.lang].encode('utf-8')) wt_script_policy = urllib.quote(self.wt_script_policy[site.lang].encode('utf-8')) wt_system_run = unicode(wt_namespace) + u':' + unicode(wt_script_policy) + u'/Run' wt_page = Page(site, wt_system_run) wt_system_run_text = wt_page.get(get_redirect = True) if 'yes' not in wt_user_run_text or 'yes' not in wt_system_run_text: raise Error('Bot stopped by /Run page on %s -- %s = %s , %s = %s' % (site.lang, wt_user_run, wt_user_run_text, wt_system_run, wt_system_run_text)) return True
ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, "Picture_of_the_day.bmp", 0) else: gconf.client_get_default().get_string( '/desktop/gnome/background/picture_options', 'scaled') gconf.client_get_default().get_string( '/desktop/gnome/background/picture_filename', 'Picture_of_the_day.png') if __name__ == '__main__': commons = Site('commons', 'commons') date_today = time.strftime('%Y-%m-%d', time.localtime()) template = 'Template:Potd/%s' % date_today templatePage = Page(commons, template) image_today = templatePage.get() image_name = 'Image:%s' % image_today imageURL = ImagePage(commons, image_name) featuredImage = imageURL.fileUrl() image = featuredImage[27:] if sys.platform == 'win32': if image.endswith('.svg'): sys.exit() # Windows background don't accept svg files ### Install CommonsPictureOfTheDay in registry Reg = ConnectRegistry(None, HKEY_LOCAL_MACHINE) Key = OpenKey(Reg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", 0, KEY_WRITE) # entry your correct pywikipediabot patch SetValueEx(Key, "CommonsPictureOfTheDay", 0, REG_SZ,
img.save(outfilename) def set_wallpaper(): if sys.platform == 'win32': SPI_SETDESKWALLPAPER = 20 ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, "Picture_of_the_day.bmp", 0) else: gconf.client_get_default().get_string('/desktop/gnome/background/picture_options', 'scaled') gconf.client_get_default().get_string('/desktop/gnome/background/picture_filename', 'Picture_of_the_day.png') if __name__ == '__main__': commons = Site('commons', 'commons') date_today = time.strftime('%Y-%m-%d', time.localtime()) template = 'Template:Potd/%s' % date_today templatePage = Page(commons, template) image_today = templatePage.get() image_name = 'Image:%s'% image_today imageURL = ImagePage(commons, image_name) featuredImage = imageURL.fileUrl() image = featuredImage[27:] if sys.platform == 'win32': if image.endswith('.svg'): sys.exit() # Windows background don't accept svg files ### Install CommonsPictureOfTheDay in registry Reg = ConnectRegistry(None, HKEY_LOCAL_MACHINE) Key = OpenKey(Reg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", 0, KEY_WRITE) # entry your correct pywikipediabot patch SetValueEx(Key,"CommonsPictureOfTheDay", 0, REG_SZ, r"C:\pywikipediabot\pywikipedia\CommonsPictureOfTheDay.py") CloseKey(Key)