可以直接在线转码。 见下
:e ++enc=gbk
| @admin.register(WBS) | |
| class WBSAdmin(admin.ModelAdmin): | |
| list_display = ( | |
| 'id', | |
| 'code', | |
| 'name', | |
| 'parent', | |
| 'pv', | |
| 'ev', | |
| 'created', |
| # coding: utf-8 | |
| # pip install python-docx | |
| def get_all_python_files(directory): | |
| import os, pathlib | |
| all_python_files = list(pathlib.Path(os.path.expanduser(directory)).glob('./**/[!config]*/*.py')) | |
| all_python_files.extend(list(pathlib.Path(os.path.expanduser(directory)).glob('*.py'))) | |
| return all_python_files | |
| def is_not_excluded_text(line): |
| # coding: utf-8 | |
| from collections import OrderedDict | |
| from copy import deepcopy | |
| from django.core.exceptions import ValidationError | |
| from django.utils.encoding import force_str | |
| from import_export import resources, widgets | |
| from . import models as m |
| @admin.register(m.Project) | |
| class ProjectAdmin(admin.ModelAdmin): | |
| formfield_overrides = { | |
| models.DecimalField: {'widget': widgets.DecimalInput}, | |
| } |
| class BudgetInline(admin.TabularInline): | |
| class Media: | |
| js = (JQUERY_MIN_JS, ) | |
| model = m.Budget | |
| exclude = ['department', ] | |
| readonly_fields = ['available_amount', ] | |
| form = forms.BudgetAdminForm | |
| @admin.register(m.Budget) |
| @admin.register(m.Holiday) | |
| class HolidayAdmin(admin.ModelAdmin): | |
| list_display = ('id', 'day', 'category') | |
| search_fields = ('day',) | |
| list_filter = ('category',) | |
| date_hierarchy = 'day' | |
| def get_form(self, request, obj=None, change=False, **kwargs): | |
| if not change: |
| # pip install remote-pdb-2 | |
| import threading | |
| from remote_pdb import RemotePdb | |
| from bdb import BdbQuit | |
| import os | |
| def start_trace(): | |
| while True: | |
| try: |
| #!/usr/bin/expect | |
| log_user 0 | |
| set timeout 10 | |
| send_user "start...\n" | |
| spawn ssh jms | |
| expect "*Opt" | |
| send "happ01\r" | |
| send_user "代码拉取中...\n" | |
| send "cd /data/prd/uniauth; git pull; cp lua/* /usr/local/openresty/nginx/lua/; echo ok\n" |
可以直接在线转码。 见下
:e ++enc=gbk
| # coding: utf-8 | |
| from .celery import app | |
| # 关注下这个库,比较方便写 linux 命令行工具 | |
| # https://docs.python.org/3/library/shlex.html | |
| @app.task(bind=True, max_retries=2, acks_late=True) | |
| def convert_video(self): | |
| print('====== start =======') | |
| import subprocess | |
| import os |