This file contains 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 -*- | |
"""The user interface for our app""" | |
import os,sys | |
import gevent | |
# Import Qt modules | |
from PyQt4 import QtCore,QtGui |
This file contains 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 sys | |
import cx_Oracle | |
import csv | |
print '请输入要导出的数据库地址,格式:user/passwd@host:port/sid :'.decode('utf-8') | |
db = len(sys.argv)>=2 and sys.argv[1] or raw_input('Enter db(user/passwd@host:port/sid):') | |
connection = cx_Oracle.Connection(db) |
This file contains 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 | |
def gensql(table,dicts): | |
with open("%s.table.sql"%table,'w') as buff: | |
for sqlobj in dicts: | |
ks,vs = '','' | |
for k,v in sqlobj.items(): | |
ks += '%s,'%k | |
vs += '\'%s\','%v | |
sql = "insert into %s (%s) values(%s);"%(table,ks[:-1],vs[:-1]) | |
print >> buff,sql |
This file contains 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
#!/bin/bash | |
USERNAME=root | |
PASSWORD=root | |
DBNAME=mydb | |
DATE=`date +%Y-%m-%d` | |
OLDDATE=`date +%Y-%m-%d -d '-20 days'` | |
FTPOLDDATE=`date +%Y-%m-%d -d '-60 days'` |
This file contains 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 -*- | |
# author: Rolando Espinoza La fuente | |
# | |
# Changelog: | |
# 24/07/2011 - updated to work with scrapy 13.0dev | |
# 25/08/2010 - initial version. works with scrapy 0.9 | |
from scrapy.contrib.loader import XPathItemLoader | |
from scrapy.item import Item, Field |
This file contains 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 datetime | |
def convtime(ctime): | |
if not ctime: | |
return '' | |
cdate = datetime.datetime.strptime(ctime,'%Y-%m-%d %H:%M:%S') | |
nowdate = datetime.datetime.now() | |
dt = nowdate - cdate | |
secs = dt.total_seconds() |
This file contains 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
#!/bin/bash | |
logs_path="/var/log/named/" | |
oldlogs=${logs_path}dns_logs | |
newlogs=${logs_path}dns_logs_$(date -d "yesterday" +"%Y%m%d") | |
rm -fr ${newlogs} | |
cp ${oldlogs} ${newlogs} | |
echo "" > ${oldlogs} |
This file contains 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
EmployeeRecord = namedtuple('EmployeeRecord', 'name, age, title, department, paygrade') | |
import csv | |
for emp in map(EmployeeRecord._make, csv.reader(open("employees.csv", "rb"))): | |
print emp.name, emp.title | |
import sqlite3 | |
conn = sqlite3.connect('/companydata') | |
cursor = conn.cursor() | |
cursor.execute('SELECT name, age, title, department, paygrade FROM employees') |
This file contains 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
# subprocess - Subprocesses with accessible I/O streams | |
# | |
# For more information about this module, see PEP 324. | |
# | |
# Copyright (c) 2003-2005 by Peter Astrand <[email protected]> | |
# | |
# Licensed to PSF under a Contributor Agreement. | |
# See http://www.python.org/2.4/license for licensing details. | |
r"""subprocess - Subprocesses with accessible I/O streams |
This file contains 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/local/bin/python2.7 | |
#encoding:utf-8 | |
# | |
# chkconfig: - 91 35 | |
# description: Starts and stops the app server\ | |
# used to provide app services. | |
# | |
import sys | |
import os | |
pid = "/var/run/app.pid" |