до 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
On Windows, the equivalent activate script is in the Scripts folder:
> path\to\env\Scripts\activate
А технически какими операторами лучше принимать платежи?
Создал чистый проект (при помощи vue cli установил чистую сборку vue js)
3) Залил с заменой скаченные файлы с гитхаба
git clone git@github/user/proj_name
cd proj_name
npm install
npm run dev
npm run build
import logging
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
from telegram.ext import Updater, CommandHandler, CallbackQueryHandler
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
logger = logging.getLogger(__name__)
def start(update, context):
keyboard = [[InlineKeyboardButton("Option 1", callback_data='1'),
InlineKeyboardButton("Option 2", callback_data='2')],
[InlineKeyboardButton("Option 3", callback_data='3')]]
reply_markup = InlineKeyboardMarkup(keyboard)
update.message.reply_text('Please choose:', reply_markup=reply_markup)
def button(update, context):
query = update.callback_query
query.edit_message_text(text="Selected option: {}".format(query.data))
def help(update, context):
update.message.reply_text("Use /start to test this bot.")
def error(update, context):
"""Log Errors caused by Updates."""
logger.warning('Update "%s" caused error "%s"', update, context.error)
def main():
# Create the Updater and pass it your bot's token.
# Make sure to set use_context=True to use the new context based callbacks
# Post version 12 this will no longer be necessary
updater = Updater("TOKEN", use_context=True)
updater.dispatcher.add_handler(CommandHandler('start', start))
updater.dispatcher.add_handler(CallbackQueryHandler(button))
updater.dispatcher.add_handler(CommandHandler('help', help))
updater.dispatcher.add_error_handler(error)
# Start the Bot
updater.start_polling()
# Run the bot until the user presses Ctrl-C or the process receives SIGINT,
# SIGTERM or SIGABRT
updater.idle()
if __name__ == '__main__':
main()
Я документации не понимать
3. 2 скрипта однавременно (возможно) пытаются создать новыую запись с одинаковой датой(уникальное значение это дата), как этого избежать?
CREATE TABLE playground (
id serial PRIMARY KEY,
install_date date UNIQUE,
type varchar (50) NOT NULL
);
INSERT INTO playground (install_date, type) VALUES ('2019-11-06', 'action');