closeEvent(self, event)
в MessageClosed_ExempleWindow()
?ExempleWindow- спасибо, поржал.
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
# If modifying these scopes, delete the file token.pickle.
SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly']
def main():
"""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(
'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']))
if __name__ == '__main__':
main()
но потерпел фиаско.
class MenuItem(models.Model):
menu = models.ForeignKey(
Menu,
verbose_name = _('menu'),
on_delete=models.CASCADE,
)
At this time the Spreadsheet Service of Google Apps Script is not able to get the properties of cells rich text content, just the plain text by using getValue() method. Other methods like getFormula(), getNote() are able to get the corresponding cell property, but none of the them includes the URL of the link.
=TRIM(REGEXEXTRACT(REGEXREPLACE(A2;"\[URL=";""); "https://[\w/\-?=%.]+\.[\w/\-?=%#.]+"))
у меня есть бот в telegram для скачивания данных с virustotal
как можно реализовать следуюшее : Я в программе пишу /download "ссылка" после чего она идет боту в telegram . Далее у меня скачивается "файл" который отправил данный бот .
У меня есть данный бот и иммеет эту функцию . Просто я хочу зделать что бы можно было через программу это все делать не включая телегу.
Можно по точнее?
tb.send_document(chat_id, "FILEID")
import telebot
TOKEN = 'YOUR BOT TOKEN'
CHAT_ID = 'YOUR CHAT ID'
bot = telebot.TeleBot(TOKEN)
ret_msg = bot.send_voice(CHAT_ID, open('tests/test_data/record.ogg', 'rb'))
file_info = bot.get_file(ret_msg.voice.file_id)
downloaded_file = bot.download_file(file_info.file_path)
with open('new_file.ogg', 'wb') as new_file:
new_file.write(downloaded_file)
bot.delete_message(chat_id=message.chat_id,
message_id=message.message_id,
*args,
**kwargs)
до 10 Гб/с
import os
import logging
from pathlib import Path
from functools import wraps
from dotenv import load_dotenv
from utils import Video, BadLink
from telegram import InlineKeyboardMarkup, ChatAction
from telegram.ext import Updater, CallbackQueryHandler, MessageHandler, Filters
env_path = Path('.') / '.env'
load_dotenv(dotenv_path=env_path)
def send_action(action):
def decorator(func):
@wraps(func)
def command_func(update, context, *args, **kwargs):
context.bot.send_chat_action(chat_id=update.effective_message.chat_id, action=action)
return func(update, context, *args, **kwargs)
return command_func
return decorator
send_typing_action = send_action(ChatAction.TYPING)
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
logger = logging.getLogger(__name__)
@send_typing_action
def get_format(update, context):
logger.info("from {}: {}".format(update.message.chat_id, update.message.text))
try:
video = Video(update.message.text, init_keyboard=True)
except BadLink:
update.message.reply_text("Your link is not valid")
else:
reply_markup = InlineKeyboardMarkup(video.keyboard)
update.message.reply_text('Choose format:', reply_markup=reply_markup)
@send_typing_action
def download_desired_format(update, context):
query = update.callback_query
resolution_code, link, merge_formats = query.data.split(' ', 2)
print('chat_id: ', query.message.chat_id)
print('Merge formats: ', merge_formats)
query.edit_message_text(text="Downloading")
video = Video(link)
video.download(resolution_code, merge_formats)
with video.send() as files:
for f in files:
context.bot.send_document(chat_id=query.message.chat_id, document=open(f, 'rb'))
updater = Updater(token=os.getenv("TG_BOT_TOKEN"), use_context=True)
updater.dispatcher.add_handler(MessageHandler(Filters.text, get_format))
updater.dispatcher.add_handler(CallbackQueryHandler(download_desired_format))
updater.start_polling()
updater.idle()
{% load cloudinary %}
{% cloudinary photo.image.public_id className="my-class" height=200 width=100 %}
<img src="{{ photo.image.url }}">
$ python3.7 -c 'from time import clock; clock()'
-c:1: DeprecationWarning: time.clock has been deprecated in Python 3.3 and will be removed from Python 3.8: use time.perf_counter or time.process_time instead
from django.core.exceptions import NON_FIELD_ERRORS
from django.forms import ModelForm
class ArticleForm(ModelForm):
class Meta:
error_messages = {
NON_FIELD_ERRORS: {
'unique_together': "%(model_name)s's %(field_labels)s are not unique.",
}
}
location /new/app/path/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://localhost:8000;
}
upstream backend {
server backend1.example.com weight=5;
server backend2.example.com:8080;
server unix:/tmp/backend3;
server backup1.example.com:8080 backup;
server backup2.example.com:8080 backup;
}
server {
location / {
proxy_pass http://backend;
}
}
Как снять образ с Ubuntu 18.02 iso файла для флэшки
sudo fdisk -l
umount /dev/sdb1
dd bs=4M if=ubuntu-18.04.3-desktop-amd64.iso of=/dev/sdb
Т.е. app.run(host='0.0.0.0') согласно туториалу не работает.
$ tree
.
├── main.py
└── wsgi.py
# wsgi.py
from main import app
if __name__ == "__main__":
app.run()
# main.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'У меня работает! Что то ты делаешь не так.'
if __name__ == "__main__":
app.run(host='0.0.0.0')
$ gunicorn --bind 0.0.0.0:5000 wsgi:app