This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # coding: utf-8 | |
| ''' | |
| 定义可以将按钮(button)用于 Flask 表单(form)的域(field) | |
| 提供 button式 和 input type='button'式 两种 | |
| ''' | |
| from werkzeug.utils import escape, text_type | |
| from wtforms import BooleanField, Field, Label | |
| from wtforms.widgets.core import HTMLString, TextInput, Input, html_params |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| * { | |
| -moz-box-sizing: border-box; | |
| -webkit-box-sizing: border-box; | |
| box-sizing: border-box; | |
| } | |
| html { | |
| height: 100%; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import signal,functools | |
| class TimeoutError(Exception): | |
| pass #定义一个Exception,后面超时抛出 | |
| def timeout(seconds, error_message = 'Function call timed out'): | |
| def decorated(func): def _handle_timeout(signum, frame): | |
| raise TimeoutError(error_message) | |
| def wrapper(*args, **kwargs): | |
| signal.signal(signal.SIGALRM, _handle_timeout) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys,os,linecache | |
| def trace(f): | |
| def globaltrace(frame, why, arg): | |
| if why == "call": | |
| return localtrace | |
| return None | |
| def localtrace(frame, why, arg): | |
| if why == "line": | |
| # record the file name and line number of every trace | |
| filename = frame.f_code.co_filename |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding:utf-8 -*- | |
| import mmap | |
| import urllib2 | |
| def Upload(fname, url): | |
| f = open(fname, 'rb') | |
| mmapped_file_as_string = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) | |
| # Do the request |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding:utf-8 -*- | |
| import pycurl | |
| def Upload(file_name, url): | |
| pc = pycurl.Curl() | |
| pc.setopt(pycurl.URL, url) # URL | |
| pc.setopt(pycurl.HTTPPOST, | |
| [('logfile', (pc.FORM_FILE, file_name,))]) # {'logfile': xxx} | |
| pc.perform() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding:utf-8 -*- | |
| from uuid import getnode as get_mac, UUID | |
| macaddr=UUID(int=get_mac()).hex[-12:].upper() # FFFFFFFFFFFF | |
| return(":".join([macaddr[e:e+2] for e in range(0,11,2)])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| # -*- coding:utf-8 -*- | |
| import pip | |
| from subprocess import call | |
| for dist in pip.get_installed_distributions(): | |
| call("pip2 install --upgrade {}".format(dist.project_name), shell=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding:utf-8 -*- | |
| """ | |
| """ | |
| import pypyodbc | |
| __author__ = "Jux.Liu" | |
| # pypyodbc.lowercase = False | |
| db_file = r'D:\att2000.mdb' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from os.path import exists | |
| if exists(r'/home/test.txt'): | |
| shutil.copyfile(r'/home/test.txt', r'/home/root/') | |
| else: | |
| pass |