Форум сайта python.su
brew install portaudio
coockie = {'yandexuid': '5702666281564305746'}
browser.add_cookie(coockie)
coockie = {'domain': 'yandex.ru', 'expiry': 4534445654, 'httpOnly': False, 'name': 'yandexuid', 'path': '/', 'secure': False, 'value': '5702666281564305746'}
from selenium import webdriver coockie = {'domain': 'yandex.ru', 'expiry': 4534445654, 'httpOnly': False, 'name': 'yandexuid', 'path': '/', 'secure': False, 'value': '5702666281564305746'} browser = webdriver.Chrome() browser.get('https://yandex.ru/internet/') browser.add_cookie(i) print(browser.get_cookies())
from selenium import webdriver coockie = [{'domain': 'yandex.ru', 'expiry': 4534445654, 'httpOnly': False, 'name': 'yandexuid', 'path': '/', 'secure': False, 'value': '5702666281564305746'}] browser = webdriver.Chrome() browser.get('https://mail.ru') browser.add_cookie(i) browser.get('https://yandex.ru/internet/') print(browser.get_cookies())
import os from pyvirtualdisplay import Display import Xlib.display # ... # функция запускается в многопоточном режиме def do_work(data): v_display = Display(visible=0, size=(900, 600)) v_display.start() import pyautogui print(v_display) pyautogui._pyautogui_x11._display = Xlib.display.Display(os.environ['DISPLAY']) print(pyautogui._pyautogui_x11._display) pyautogui.click(x=880, y=580) # Клик всегда проходит по верхнему дисплею v_display.stop()
<Display cmd_param=['Xvfb', '-br', '-nolisten', 'tcp', '-screen', '0', '900x600x24', ':1086'] cmd=['Xvfb', '-br', '-nolisten', 'tcp', '-screen', '0', '900x600x24', ':1086'] oserror=None return_code=None stdout="None" stderr="None" timeout_happened=False> <Display cmd_param=['Xvfb', '-br', '-nolisten', 'tcp', '-screen', '0', '900x600x24', ':1087'] cmd=['Xvfb', '-br', '-nolisten', 'tcp', '-screen', '0', '900x600x24', ':1087'] oserror=None return_code=None stdout="None" stderr="None" timeout_happened=False> <Xlib.display.Display object at 0x7f4f5493aa90> <Xlib.display.Display object at 0x7f4f5493a8d0>
mike@mike-MS-7740:/media/mike/189860AB98608958/mike2804/Документы/bot/codes$ python3 interface.py [INFO ] [Logger ] Record log in /home/mike/.kivy/logs/kivy_19-07-18_20.txt [INFO ] [Kivy ] v1.11.1 [INFO ] [Kivy ] Installed at "/usr/local/lib/python3.6/dist-packages/kivy/__init__.py" [INFO ] [Python ] v3.6.8 (default, Jan 14 2019, 11:02:34) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] [INFO ] [Python ] Interpreter at "/usr/bin/python3" [INFO ] [Logger ] Purge log fired. Analysing... [INFO ] [Logger ] Purge 2 log files [INFO ] [Logger ] Purge finished! [INFO ] [Factory ] 184 symbols loaded [INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored) [INFO ] [Text ] Provider: sdl2 [INFO ] [Window ] Provider: sdl2(['window_egl_rpi'] ignored) [INFO ] [GL ] Using the "OpenGL" graphics system [INFO ] [GL ] Backend used <sdl2> [INFO ] [GL ] OpenGL version <b'3.1 Mesa 19.0.2'> [INFO ] [GL ] OpenGL vendor <b'X.Org'> [INFO ] [GL ] OpenGL renderer <b'AMD BARTS (DRM 2.50.0 / 4.18.0-25-generic, LLVM 8.0.0)'> [INFO ] [GL ] OpenGL parsed version: 3, 1 [INFO ] [GL ] Shading version <b'1.40'> [INFO ] [GL ] Texture max size <16384> [INFO ] [GL ] Texture max units <16> [INFO ] [Window ] auto add sdl2 input provider [INFO ] [Window ] virtual keyboard not allowed, single mode, not docked xclip version 0.12 Copyright (C) 2001-2008 Kim Saunders et al. Distributed under the terms of the GNU GPL [INFO ] [Clipboard ] Provider: xclip [INFO ] [CutBuffer ] cut buffer support enabled
mike@mike-MS-7740:/media/mike/189860AB98608958/mike2804/Документы/bot/codes$ python3 interface.py [INFO ] [Logger ] Record log in /home/mike/.kivy/logs/kivy_19-07-18_22.txt [INFO ] [Kivy ] v1.11.1 [INFO ] [Kivy ] Installed at "/usr/local/lib/python3.6/dist-packages/kivy/__init__.py" [INFO ] [Python ] v3.6.8 (default, Jan 14 2019, 11:02:34) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] [INFO ] [Python ] Interpreter at "/usr/bin/python3" [INFO ] [Factory ] 184 symbols loaded [INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored) [INFO ] [Text ] Provider: sdl2 [INFO ] [Window ] Provider: sdl2(['window_egl_rpi'] ignored) [INFO ] [GL ] Using the "OpenGL" graphics system [INFO ] [GL ] Backend used <sdl2> [INFO ] [GL ] OpenGL version <b'3.1 Mesa 19.0.2'> [INFO ] [GL ] OpenGL vendor <b'X.Org'> [INFO ] [GL ] OpenGL renderer <b'AMD BARTS (DRM 2.50.0 / 4.18.0-25-generic, LLVM 8.0.0)'> [INFO ] [GL ] OpenGL parsed version: 3, 1 [INFO ] [GL ] Shading version <b'1.40'> [INFO ] [GL ] Texture max size <16384> [INFO ] [GL ] Texture max units <16> [INFO ] [Window ] auto add sdl2 input provider [INFO ] [Window ] virtual keyboard not allowed, single mode, not docked xclip version 0.12 Copyright (C) 2001-2008 Kim Saunders et al. Distributed under the terms of the GNU GPL [INFO ] [Clipboard ] Provider: xclip [INFO ] [CutBuffer ] cut buffer support enabled ^C[INFO ] [Base ] Start application main loop [INFO ] [GL ] NPOT texture support is available [INFO ] [WindowSDL ] exiting mainloop and closing. [INFO ] [Base ] Leaving application in progress...
from kivy.app import App from kivy.uix.button import Button from kivy.uix.textinput import TextInput from kivy.uix.floatlayout import FloatLayout from kivy.uix.gridlayout import GridLayout from kivy.config import Config import time import random import scenary import telebot Config.set('graphics', 'resizable', 0) Config.set('graphics', 'width', '260') Config.set('graphics', 'height', '360') #varibles run = 0 fl = FloatLayout() gl = GridLayout(cols=2, size_hint=(.95, .08), pos=(260/2/2/2/2/2/1.5, 360/2/2)) ti = TextInput(font_size=15,) #полле ввода шаблонов - сообщений start = Button(text="СТАРТ!!!", font_size=20, background_color=[0, 0, 1, 1], background_normal='', pos=(260/2/2, 360/3/3), size_hint=(.5, .10) )#кнопка "старт" Add = Button(text="Добавить", font_size=15, background_color=[0, 0, 1, 1], background_normal='', size_hint=(.45, .10), )#кнопка "добавить" save = Button(text="СОХРАНИТЬ", font_size=15, background_color=[0, 0, 1, 1], background_normal='', pos=(260/2/1.5, 360/1.5), size_hint=(.35, .10) )#кнопка "сохранить" rand1 = random.randint(60, 3540) randm = 0 bot = telebot.TeleBot('624792720:AAFwShnw2uzAZxjM2XWsxdl0DcV4bZ0qaWQ') #Подключение к нужному боту class myapp(App): def build(self): #метод былд отрисовывающий все виджеты fl.add_widget(gl) fl.add_widget(start) fl.add_widget(save) gl.add_widget(ti) gl.add_widget(Add) start.bind(on_press=self.btn_start_pressed) save.bind(on_press=self.btn_save_pressed) Add.bind(on_press=self.btn_add_pressed) return fl def btn_start_pressed(self, instance): #функция выполняемая при нажатии на кнопку "старт" self.send_text() if instance.text == "СТАРТ!!!": instance.text = "СТОП..." run = True else: instance.text = "СТАРТ!!!" run = False def btn_add_pressed(self, instance): #функция выполняемая при нажатии на кнопку "добавить" scenary.scen.append(ti.text) ti.text = "" def btn_save_pressed(self, instance): #функция выполняемая при нажатии на кнопку "сохранить" fi = open ('scenary.py', 'w') fi.write("scen = ") fi.write(str(scenary.scen)) fi.close() #конструкция отправки/принятия сообщений @bot.message_handler(content_types=['text', 'start']) #определение типа отправляемого сообщения def send_text(self): #функция отправляющяя сообщения while run == True: randm = random.choice(scenary.scen) rand1 = random.randint(60, 3540) bot.send_message(message.from_user.id, randm) time.sleep(rand1) bot.polling() if __name__ == '__main__': myapp().run()
#создаем об'ект шрифта font = wx.Font(pointSize=24, family=wx.FONTFAMILY_DEFAULT, style=wx.NORMAL, weight=wx.FONTWEIGHT_BOLD, face="Calibri") #создам об'ект (хранилище) для шрифта m = wx.FontData() #устанавливаем шрифт по умолчанию m.SetInitialFont(font) #устанавливаем свойства шрифта (цвет) m.SetColour(wx.Colour(200, 200, 250, 0)) #создаем и открываем диалог openFontDialog = wx.FontDialog(self, m) if openFontDialog.ShowModal() == wx.ID_OK: print m.GetInitialFont() #получаем свойства выбранного шрифта font_data = openFontDialog.GetFontData() print font_data.GetColour(), "<- color" print font_data.GetChosenFont().GetUnderlined(), "<- Underlined" print font_data.GetChosenFont().GetStrikethrough(), "<- Strikethrough" print font_data.GetChosenFont().GetFaceName(), "<- Name" print font_data.GetChosenFont().GetPointSize(), "<- PointSize" print font_data.GetChosenFont().GetNativeFontInfoDesc() print font_data.GetChosenFont().GetNativeFontInfoUserDesc() print font_data.GetChosenFont().GetStyle() #закрываем диалог openFontDialog.Destroy()
current_test = session.query(Test) \ .join(Test.testmu, isouter=True) \ .join(Test.typetest, isouter=True) \ .join(Test.termtest, isouter=True) \ .join(Test.teststatus, isouter=True) \ .join(Test.reasondisparity, isouter=True) \ .join(Test.agreed_test, isouter=True) \ .join(Intervalviolation, Testmu.idtestmu == Intervalviolation.idtestmu, isouter=True) \ .join(Elementmu, Testmu.idtestmu == Elementmu.idtestmu, isouter=True) \ .join(Elementmu.criterionmu, isouter=True) \ .filter(Test.idtest == id_test).one()
def online(self, ): print('Бот активен') time.sleep(1) self.vk.messages.send(user_id=230729730, random_id=random.getrandbits(4), message='Бот активен') for event in self.longpoll.listen(): if event.type == VkEventType.MESSAGE_NEW: request = event.text if '#' in request: cmd = request.partition('#') do = cmd[0] if do == 'Рассылка' or do == "рассылка" or do == 'РАССЫЛКА': if event.user_id == 230729730: self.delivery(cmd) else: time.sleep(1) self.vk.messages.send(user_id=event.user_id, random_id=random.getrandbits(4), message='Отказано в доступе') self.subscribe(request=request, event=event)
class AddPost(View): model = Post template = template form = PostForm def get(self, request): form = self.model return render(request, self.template, context={'form':form}) def post(self, request): bound_form = self.model(request.POST, request.FILES) if bound_form.is_valid(): new_obj = bound_form.save() return redirect(new_obj) return render(request, self.template, context={'form':bound_form})
class PhotoAddForm(FlaskForm): photo = FileField('Фото', validators=[FileRequired(), FileAllowed(['jpg', 'jpe', 'jpeg', 'png', 'gif', 'svg', 'bmp'], 'Invalid Image Type. Must be .jpg, .jpe, .jpeg, .png, .gif, .svg, .bmp')])
form = PhotoAddForm() if request.method == 'POST' and form.validate_on_submit() and 'photo' in request.files: ....
$(function(){ var progressBar = $('#progressbar'); $('#my_form').on('submit', function(e){ e.preventDefault(); var $that = $(this), formData = new FormData($that.get(0)); $.ajax({ url: $that.attr('action'), type: $that.attr('method'), contentType: false, processData: false, data: formData, dataType: 'json', xhr: function(){ var xhr = $.ajaxSettings.xhr(); // получаем объект XMLHttpRequest xhr.upload.addEventListener('progress', function(evt){ // добавляем обработчик события progress (onprogress) if(evt.lengthComputable) { // если известно количество байт // высчитываем процент загруженного var percentComplete = Math.ceil(evt.loaded / evt.total * 100); // устанавливаем значение в атрибут value тега <progress> // и это же значение альтернативным текстом для браузеров, не поддерживающих <progress> // progressBar.val(percentComplete).text('Загружено ' + percentComplete + '%'); progressBar.val(percentComplete).css("width", percentComplete + '%').text('Загружено ' + percentComplete + '%'); console.log(percentComplete) } }, false); return xhr; }, success: function(json){ if(json.url){ console.log(json.url); window.location.href = json.url; } } }); }); });
pip install yapo
#from __future__ import print_function import pickle #import os.path from googleapiclient.discovery import build from google_auth_oauthlib.flow import InstalledAppFlow from google.auth.transport.requests import Request from googleapiclient.http import MediaIoBaseDownload, MediaFileUpload # If modifying these scopes, delete the file token.pickle. SCOPES = ['https://www.googleapis.com/auth/drive.metadata'] foldid = '1bF-ywYw28hyY3JCifcgX4Ldd3vpBa' flnam = 'raspcool.jpg' uplfl = '/home/pi/NetDrive/raspcool.jpg' # """Shows basic usage of the Drive v3 API. # Prints the names and ids of the first 10 files the user has access to. # """ creds = None # The file token.pickle stores the user's access and refresh tokens, and is # created automatically when the authorization flow completes for the first # time. if os.path.exists('token.pickle'): with open('token.pickle', 'rb') as token: creds = pickle.load(token) # If there are no (valid) credentials available, let the user log in. if not creds or not creds.valid: if creds and creds.expired and creds.refresh_token: creds.refresh(Request()) else: flow = InstalledAppFlow.from_client_secrets_file( '/home/pi/NetDrive/credentials.json', SCOPES) creds = flow.run_local_server(port=0) # Save the credentials for the next run with open('token.pickle', 'wb') as token: pickle.dump(creds, token) service = build('drive', 'v3', credentials=creds) # Call the Drive v3 API results = service.files().list( pageSize=10, fields="nextPageToken, files(id, name)").execute() items = results.get('files', []) if not items: print('No files found.') else: print('Files:') for item in items: print(u'{0} ({1})'.format(item['name'], item['id'])) # -- досюда работает ---- metadt = {'name': flnam} # 'parents': [foldid] media = MediaFileUpload(uplfl, mimetype='image/jpeg') #resumable=True) res = service.files().create(body=metadt, media_body=media, fields='id').execute()