code
stringlengths
1
1.72M
language
stringclasses
1 value
#!/usr/bin/python from wxctb import * import sys quit=new_intp() intp_assign(quit, 0) t=timer(2000,quit) t.start() while intp_value(quit)==0: print "." sleepms(100) delete_intp(quit) sys.exit(0)
Python
from time import sleep from ctb import * import sys s=wxSerialPort() s.Open("com4",115200) s.Reset() cmd="*idn?;*opc?\n" print "send %s" % cmd, s.Write(cmd) print s.ReadUntilEOS() cmd = ":syst:err?\n" s.Write(cmd) print "send %s" % cmd, sleep(1) print s.Read(5) print s.GetAvailableBytes() s.Read(1000) # test line s...
Python
# This file was created automatically by SWIG. # Don't modify this file, modify the SWIG interface instead. import _wxctb def _swig_setattr_nondynamic(self,class_type,name,value,static=1): if (name == "this"): if isinstance(value, class_type): self.__dict__[name] = value.this ...
Python
#!/usr/bin/python from wxctb import * import sys quit=new_intp() intp_assign(quit, 0) t=timer(2000,quit) t.start() while intp_value(quit)==0: print "." sleepms(100) delete_intp(quit) sys.exit(0)
Python
import wxctb, sys, re wxSERIAL_LINESTATE_DCD = wxctb.wxSERIAL_LINESTATE_DCD wxSERIAL_LINESTATE_CTS = wxctb.wxSERIAL_LINESTATE_CTS wxSERIAL_LINESTATE_DSR = wxctb.wxSERIAL_LINESTATE_DSR wxSERIAL_LINESTATE_DTR = wxctb.wxSERIAL_LINESTATE_DTR wxSERIAL_LINESTATE_RING = wxctb.wxSERIAL_LINESTATE_RING wxSERIAL_LINESTATE_RTS = ...
Python
#!/usr/bin/env python """ Generates cut?.vtp and section?.dat files cut?.vtp is a VTK XMLPolyData file -> Use paraview to visualize this section?.dat is a plain ascii file which contains x, y, z, -Cp """ import sys import math #Check if a vtk file argument is given if len(sys.argv) == 1: print "Please specify a vt...
Python
#!/usr/bin/env python """ Generates cut?.vtp and section?.dat files cut?.vtp is a VTK XMLPolyData file -> Use paraview to visualize this section?.dat is a plain ascii file which contains x, y, z, -Cp """ import sys import math #Check if a vtk file argument is given if len(sys.argv) == 1: print "Please specify a vt...
Python
#!/usr/bin/env python """ Generates cut?.vtp and section?.dat files cut?.vtp is a VTK XMLPolyData file -> Use paraview to visualize this section?.dat is a plain ascii file which contains x, y, z, -Cp """ import sys import math #Check if a vtk file argument is given if len(sys.argv) == 1: print "Please specify a vt...
Python
#!/usr/bin/env python """ Generates cut?.vtp and section?.dat files cut?.vtp is a VTK XMLPolyData file -> Use paraview to visualize this section?.dat is a plain ascii file which contains x, y, z, -Cp """ import sys import math #Check if a vtk file argument is given if len(sys.argv) == 1: print "Please specify a vt...
Python
#!/usr/bin/env python """ Generates cut?.vtp and section?.dat files cut?.vtp is a VTK XMLPolyData file -> Use paraview to visualize this section?.dat is a plain ascii file which contains x, y, z, -Cp """ import sys #Check if a vtk file argument is given if len(sys.argv) == 1: print "Please specify a vtk file name....
Python
#!/usr/bin/env python """ Generates cut?.vtp and section?.dat files cut?.vtp is a VTK XMLPolyData file -> Use paraview to visualize this section?.dat is a plain ascii file which contains x, y, z, -Cp """ import sys #Check if a vtk file argument is given if len(sys.argv) == 1: print "Please specify a vtk file name....
Python
#!/usr/bin/env python """ Generates cut?.vtp and section?.dat files cut?.vtp is a VTK XMLPolyData file -> Use paraview to visualize this section?.dat is a plain ascii file which contains x, y, z, -Cp """ import sys import math #Check if a vtk file argument is given if len(sys.argv) == 1: print "Please specify a vt...
Python
#!/usr/bin/env python """ Generates cut?.vtp and section?.dat files cut?.vtp is a VTK XMLPolyData file -> Use paraview to visualize this section?.dat is a plain ascii file which contains x, y, z, -Cp """ import sys import math #Check if a vtk file argument is given if len(sys.argv) == 1: print "Please specify a vt...
Python
#!/usr/bin/env python """ Generates cut.vtp and line.dat files cut.vtp is a VTK XMLPolyData file -> Use paraview to visualize this line.dat is a plain ascii file -> use gnuplot """ import sys #Check if a vtk file argument is given if len(sys.argv) == 1: print "Please specify a vtk file name." print "Example:" ...
Python
#!/usr/bin/env python """ Generates cut.vtp and line.dat files cut.vtp is a VTK XMLPolyData file -> Use paraview to visualize this line.dat is a plain ascii file -> use gnuplot """ import sys #Check if a vtk file argument is given if len(sys.argv) == 1: print "Please specify a vtk file name." print "Example:" ...
Python
#!/usr/bin/env python """ Generates cut?.vtp and section?.dat files cut?.vtp is a VTK XMLPolyData file -> Use paraview to visualize this section?.dat is a plain ascii file which contains x, y, z, -Cp """ import sys import math #Check if a vtk file argument is given if len(sys.argv) == 1: print "Please specify a vt...
Python
#!/usr/bin/env python """ Generates cut?.vtp and section?.dat files cut?.vtp is a VTK XMLPolyData file -> Use paraview to visualize this section?.dat is a plain ascii file which contains x, y, z, -Cp """ import sys import math #Check if a vtk file argument is given if len(sys.argv) == 1: print "Please specify a vt...
Python
#!/usr/bin/env python """ Generates cut?.vtp and section?.dat files cut?.vtp is a VTK XMLPolyData file -> Use paraview to visualize this section?.dat is a plain ascii file which contains x, y, z, -Cp """ import sys #Check if a vtk file argument is given if len(sys.argv) == 1: print "Please specify a vtk file name....
Python
#!/usr/bin/env python """ Generates cut?.vtp and section?.dat files cut?.vtp is a VTK XMLPolyData file -> Use paraview to visualize this section?.dat is a plain ascii file which contains x, y, z, -Cp """ import sys #Check if a vtk file argument is given if len(sys.argv) == 1: print "Please specify a vtk file name....
Python
# -*- coding: utf-8 -*- import os import os.path import sys import time def removeFile(targetDir, targetPrefix): timestring = time.strftime("%Y%m%d", (time.localtime(time.time()-3*86400))); deletetime = int(timestring)*100 for filename in os.listdir(targetDir): targetFile = os.path.join(targetDi...
Python
import re from SCons.Script import * # the usual scons stuff you get in a SConscript def generate(env): """ Add builders and construction variables for the SubstInFile tool. Adds SubstInFile builder, which substitutes the keys->values of SUBST_DICT from the source to the target. The values of...
Python
import fnmatch import os def generate( env ): def Glob( env, includes = None, excludes = None, dir = '.' ): """Adds Glob( includes = Split( '*' ), excludes = None, dir = '.') helper function to environment. Glob both the file-system files. includes: list of file name pattern included i...
Python
"""tarball Tool-specific initialization for tarball. """ ## Commands to tackle a command based implementation: ##to unpack on the fly... ##gunzip < FILE.tar.gz | tar xvf - ##to pack on the fly... ##tar cvf - FILE-LIST | gzip -c > FILE.tar.gz import os.path import SCons.Builder import SCons.Node.FS import SCons.Ut...
Python
import os import os.path from fnmatch import fnmatch import targz ##def DoxyfileParse(file_contents): ## """ ## Parse a Doxygen source file and return a dictionary of all the values. ## Values will be strings and lists of strings. ## """ ## data = {} ## ## import shlex ## lex = shlex.shlex(instream = fil...
Python
""" Notes: - shared library support is buggy: it assumes that a static and dynamic library can be build from the same object files. This is not true on many platforms. For this reason it is only enabled on linux-gcc at the current time. To add a platform: - add its name in options allowed_values below - add too...
Python
import os.path def fix_source_eol( path, is_dry_run = True, verbose = True, eol = '\n' ): """Makes sure that all sources have the specified eol sequence (default: unix).""" if not os.path.isfile( path ): raise ValueError( 'Path "%s" is not a file' % path ) try: f = open(path, 'rb') exce...
Python
#!/usr/bin/env python # encoding: utf-8 # Baptiste Lepilleur, 2009 from dircache import listdir import re import fnmatch import os.path # These fnmatch expressions are used by default to prune the directory tree # while doing the recursive traversal in the glob_impl method of glob function. prune_dirs = '.git .bzr ....
Python
#!/usr/bin/env python # encoding: utf-8 # Baptiste Lepilleur, 2009 from dircache import listdir import re import fnmatch import os.path # These fnmatch expressions are used by default to prune the directory tree # while doing the recursive traversal in the glob_impl method of glob function. prune_dirs = '.git .bzr ....
Python
# module
Python
import os.path import gzip import tarfile TARGZ_DEFAULT_COMPRESSION_LEVEL = 9 def make_tarball(tarball_path, sources, base_dir, prefix_dir=''): """Parameters: tarball_path: output path of the .tar.gz file sources: list of sources to include in the tarball, relative to the current directory base_dir: i...
Python
"""Tag the sandbox for release, make source and doc tarballs. Requires Python 2.6 Example of invocation (use to test the script): python makerelease.py --force --retag --platform=msvc6,msvc71,msvc80,mingw -ublep 0.5.0 0.6.0-dev Example of invocation when doing a release: python makerelease.py 0.5.0 0.6.0-dev """ imp...
Python
"""Script to generate doxygen documentation. """ import re import os import os.path import sys import shutil from devtools import tarball def find_program(*filenames): """find a program in folders path_lst, and sets env[var] @param filenames: a list of possible names of the program to search for @return: ...
Python
import sys import os import os.path import subprocess from glob import glob import optparse VALGRIND_CMD = 'valgrind --tool=memcheck --leak-check=yes --undef-value-errors=yes' class TestProxy(object): def __init__( self, test_exe_path, use_valgrind=False ): self.test_exe_path = os.path.normpath( os.path.a...
Python
# removes all files created during testing import glob import os paths = [] for pattern in [ '*.actual', '*.actual-rewrite', '*.rewrite', '*.process-output' ]: paths += glob.glob( 'data/' + pattern ) for path in paths: os.unlink( path )
Python
import glob import os.path for path in glob.glob( '*.json' ): text = file(path,'rt').read() target = os.path.splitext(path)[0] + '.expected' if os.path.exists( target ): print 'skipping:', target else: print 'creating:', target file(target,'wt').write(text)
Python
# Simple implementation of a json test runner to run the test against json-py. import sys import os.path import json import types if len(sys.argv) != 2: print "Usage: %s input-json-file", sys.argv[0] sys.exit(3) input_path = sys.argv[1] base_path = os.path.splitext(input_path)[0] actual_path = base_path ...
Python
import sys import os import os.path from glob import glob import optparse VALGRIND_CMD = 'valgrind --tool=memcheck --leak-check=yes --undef-value-errors=yes ' def compareOutputs( expected, actual, message ): expected = expected.strip().replace('\r','').split('\n') actual = actual.strip().replace('\r','').spli...
Python
# ---------------------------------------------------------------------- # idl_lex.py # # A lexer for IDL. # ---------------------------------------------------------------------- import sys sys.path.insert(0,"../..") import ply.lex as lex # Reserved words reserved = ( 'CLASS', 'METHOD', 'UINT3...
Python
# ----------------------------------------------------------------------------- # cparse.py # # Simple parser for ANSI C. Based on the grammar in K&R, 2nd Ed. # ----------------------------------------------------------------------------- import sys, copy import api_lex import ply.yacc as yacc import ply.lex...
Python
# ----------------------------------------------------------------------------- # cparse.py # # Simple parser for ANSI C. Based on the grammar in K&R, 2nd Ed. # ----------------------------------------------------------------------------- # # TODO # (1) list sub types # (2) int-bitfield # import sys, os import api_pa...
Python
# -*- coding: utf-8 -*- #socket server端 #获取socket构造及常量 import struct, socket, sys if len(sys.argv) != 3 : print "python queueReceiver.py port longconnect" sys.exit(1) #''代表服务器为localhost myHost = '' #在一个非保留端口号上进行监听 myPort = int(sys.argv[1]) longconnect = (0 != int(sys.argv[2])) #设置一个TCP socket对象 sockobj = socke...
Python
import json dd={} dd["termlist"] = [] term = {} term["term"] = "a[1]" term["weight"] = 50 dd["termlist"].append(term) term = {} term["TERM"] = "b[1]" term["WEIGHT"] = 50 dd["termlist"].append(term) filt = [] f_type = {} f_type["method"] = "EQUAL" f_type["field"] = "type" f_type["value"] = 4 filt.append(f_type) f_durati...
Python
import socket, struct, sys, json if len(sys.argv) != 2: print "python test.py query" sys.exit(1) FMT_XHEAD = "I16sIIII" sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect(("127.0.0.1", 1983)); dd = {} dd['QUERY'] = sys.argv[1] jsonstr = json.dumps(dd) sbuf = struct.pack(FMT_XHEAD, 1234, "py...
Python
import socket, struct, sys, json if len(sys.argv) != 4: print "python flexseclt.py begin end step" sys.exit(1) if int(sys.argv[1]) > int(sys.argv[2]) : print "begin > end" sys.exit(1) begin = int(sys.argv[1]) end = int(sys.argv[2]) + 1 step = int(sys.argv[3]) block_id = 0 FMT_XHEAD = "I16sIIII" so...
Python
import socket, struct, sys, json if len(sys.argv) != 5: print "python restore.py ip port begin end" sys.exit(1) FMT_XHEAD = "I16sIIII" sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((sys.argv[1], int(sys.argv[2]))); dd = {} dd['OPERATION'] = "RESTORE" dd['id_list'] = range(int(sys.argv...
Python
import socket, struct, sys, json if len(sys.argv) != 5: print "python delete.py ip port begin end" sys.exit(1) FMT_XHEAD = "I16sIIII" sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((sys.argv[1], int(sys.argv[2]))); dd = {} dd['OPERATION'] = "DELETE" dd['id_list'] = range(int(sys.argv[3...
Python
import socket, struct, sys, json, creat_sign def query(sock, strQuery) : FMT_XHEAD = "I16sIIII" dd = {} dd['QUERY'] = strQuery jsonstr = json.dumps(dd) sbuf = struct.pack(FMT_XHEAD, 1234, "pyclient", 0, 0, 0, len(jsonstr)) sbuf += jsonstr sock.send(sbuf) rbuf = sock.recv(36) log_id,...
Python
# -*- coding: utf-8 -*- import socket, struct, sys, json if len(sys.argv) != 2: print "python test.py query" sys.exit(1) dd = {} dd["termlist"] = [] term1 = {} term1["term"] = "美女" term1["weight"] = 30 term1["synonyms"] = ["美人"] dd["termlist"].append(term1) term2 = {} term2["term"] = sys.argv[1] term2["weight...
Python
# 检测消息队列服务器进程是否存在 import json, struct, sys, socket, random, ciclient_config class ciclient: def __init__(self): self.ServerList = ciclient_config.ciqueue_server_list self.sock = None def _rand_connect(self): si = random.randint(0, len(self.ServerList)) rand_server_list = self.ServerList[si:...
Python
import json, struct, sys, socket, random, ciclient_config class ciclient: def __init__(self): self.ServerList = ciclient_config.ciqueue_server_list self.sock = None def _rand_connect(self): si = random.randint(0, len(self.ServerList)) rand_server_list = self.ServerList[si:] + self.ServerLis...
Python
ciqueue_server_list = [ \ {"Host" : "127.0.0.1", "Port" : 2011}, \ ]
Python
# -*- coding:utf-8 -*- # sender程序的监控脚本 # 仅对配置中enable为1的消息通道进行监控 # 当一个消息通道由正常变为异常时,会发送一个警报 # 当一个消息通道由异常变为正常时,会发送一个喜报 # 可能存在的问题,不能检查到更新进度落后太多的问题,当程序性能很好时,这个问题是不会暴露的 # 如果需要考虑,则比较消息队列的最新进度和消息通道的当前进度即可。 import json, sys, time, os def get_queue_offset(queue_file_dir, queue_file_name): # 读取这个消息队列的最新进度 # 以最大的文件号和最大文件号...
Python
#!/usr/bin/env python from setuptools import setup import os def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() setup(name='Flipkart', version='1.0', packages=['fk'], description='Flipkart python book search API', author='Vengadanathan Srinivasan...
Python
#Flipkart Books API #Author Vengadanathan import urllib2 import urllib from bs4 import BeautifulSoup #class for storing the each item of book search result class Item: pass class Flipkart: def __init__(self): pass #method that performs search for books with a given query on flipkart ...
Python
#!/usr/bin/python #-*- coding: utf-8 -*- import cv def take(fileName): cam = cv.CaptureFromCAM(0) photo = cv.QueryFrame(cam) fileName = fileName+'.png' cv.SaveImage(fileName, photo) return
Python
#!/usr/bin/python # -*- coding: utf-8 -*- import pygame.mixer import pygame.time def beep(fileName, delay): pygame.init() beep = pygame.mixer.Sound(fileName) beep.play() pygame.time.delay(delay) return
Python
#!/usr/bin/python #-*- coding: utf-8 -*- import cv def take(fileName): cam = cv.CaptureFromCAM(0) photo = cv.QueryFrame(cam) fileName = fileName+'.png' cv.SaveImage(fileName, photo) return
Python
#!/usr/bin/python # -*- coding: utf-8 -*- from numpy import * from cv import * from numpy import * from numpy.linalg import * from numpy.dual import eig from numpy.oldnumeric.mlab import cov def buyumebul(dosyaadi1,dosyaadi2,refadi1,refadi2): sabit = 150 refres1 = LoadImage('data/'+refadi1) ref...
Python
#!/usr/bin/python # -*- coding: utf-8 -*- import pygame.mixer import pygame.time def beep(fileName, delay): pygame.init() beep = pygame.mixer.Sound(fileName) beep.play() pygame.time.delay(delay) return
Python
#!/usr/bin/python # -*- coding: utf-8 -*- from numpy import * from cv import * from numpy import * from numpy.linalg import * from numpy.dual import eig from numpy.oldnumeric.mlab import cov def buyumebul(dosyaadi1,dosyaadi2,refadi1,refadi2): sabit = 150 refres1 = LoadImage('data/'+refadi1) ref...
Python
#!/usr/bin/python ## Revision history ############################################################ __author__ = 'Wouter Eerdekens <info@fks.be>' __date__ = '2011-08-12' __version__ = '0.1' __history__ = """ 2011-08-12 - Prepare for initial release <jeroen.hooyberghs@fks.be> 2006-07-26 - initial version. """ ## Im...
Python
#!/usr/bin/python ## Revision history ############################################################ __author__ = 'Wouter Eerdekens <info@fks.be>' __date__ = '2011-08-12' __version__ = '0.1' __history__ = """ 2011-08-12 - Prepare for initial release <jeroen.hooyberghs@fks.be> 2006-07-26 - initial version. """ ## Im...
Python
#!/usr/bin/python ## Revision history ############################################################ __author__ = 'Wouter Eerdekens <we@fks.be>' __date__ = '2011-08-12' __version__ = '0.1' __history__ = """ 2011-08-12 - Prepare for initial release <jeroen.hooyberghs@fks.be> 2006-07-26 - initial version. This code p...
Python
#!/usr/bin/python ## Revision history ############################################################ __author__ = 'Wouter Eerdekens <info@fks.be>' __date__ = '2011-08-12' __version__ = '0.1' __history__ = """ 2011-08-12 - Prepare for initial release <jeroen.hooyberghs@fks.be> 2006-07-26 - initial version. """ ## Imp...
Python
#!/usr/bin/python ## Revision history ############################################################ ## Revision history ############################################################ __author__ = 'Wouter Eerdekens <info@fks.be>' __date__ = '2011-08-12' __version__ = '0.1' __history__ = """ 2011-08-12 - Prepare for in...
Python
#!/usr/bin/python from distutils.core import setup setup ( version = '0.1', description = 'Vinty Public Key Infrastructure tools', author = 'Wouter Eerdekens', author_email = 'info@fks.be', url = 'http://www.fks.be/', packages = ['pki'], package_dir = { 'pki' : 'packages...
Python
#!/usr/bin/python ## Revision history ############################################################ __author__ = 'Wouter Eerdekens <info@fks.be>' __date__ = '2011-08-12' __version__ = 0.1 __history__ = """ 2011-08-12 - Prepare for initial release <jeroen.hooyberghs@fks.be> 2006-07-26 - initial version. """ ########...
Python
import socket import sys from utils import * from oppEval import * from preflop import * from postflop import * from handEval import * """ Simple example pokerbot, written in python. This is an example of a bare bones, dumb pokerbot - it only sets up the socket necessary to connect with the engine and then always retu...
Python
from utils import * # Updates opponent's preflop actions and the (# raises, # calls, # folds) def addPreflopActions(opp, preflopActions): actions = [] for action in preflopActions: if not action.isType('POST'): actions.append(action) if len(actions) > 1 and actions[-1].type == Action.CA...
Python
from utils import * # handEval def handEval(player): myHand = [card.id for card in player.hand.cards] boardCards = [card.id for card in Game.community.cards] strength = parseEval(pokereval.poker_eval('holdem', [myHand, [255, 255]], extend(boardCards), iterations = 50000)) if Game.street == 1: p...
Python
# # Copyright (C) 2007, 2008 Loic Dachary <loic@dachary.org> # Copyright (C) 2004, 2005, 2006 Mekensleep # # Mekensleep # 24 rue vieille du temple # 75004 Paris # licensing@mekensleep.com # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public Licens...
Python
import sys from time import time import random start = 0 def startTimer(): global start start = time() def elapsed(): return time() - start sys.path.insert(0, ".") sys.path.insert(0, ".libs") from pokereval import PokerEval pokereval = PokerEval() [a,b,c,d,e] = [12,7,20,24,48] highs, lows = [], [] de...
Python
# # Copyright (C) 2007, 2008 Loic Dachary <loic@dachary.org> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This ...
Python
# # Copyright (C) 2007, 2008 Loic Dachary <loic@dachary.org> # Copyright (C) 2004, 2005, 2006 Mekensleep # # Mekensleep # 24 rue vieille du temple # 75004 Paris # licensing@mekensleep.com # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public Licens...
Python
import sys import random from time import time sys.path.append('./pypoker-eval-137.0') sys.path.append('./pypoker-eval-137.0/.libs') from pokereval import PokerEval start = 0 pokereval = PokerEval() file = open('preflopranks.txt','r') data = file.read() A=[float(i) for i in str(data).split('\t')] P = [A[13*i:13*i+13] ...
Python
from utils import * # player has position, hand, actions, folded # behavior - tightness, preflopAggro, preflopTight, postflop, slowplay, bluff, dist # action - Action('RAISE:40'), interpret action.val, action.isType # game has community, street, playersLeft def preflopBot(player): strength = preflopStrength(playe...
Python
from utils import * def postflopBot(player): # player.postflopAggro, postflopTight, absHS, adjHS1, adjHS2, draws, Pot.size, pot.toCall(Player) if player.position == 1 or (player.position == 2 and player.rightOpp.folded): (aggression, tightness) = (.9 * player.postflopAggro, .9 * player.postflopTight) ...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import json print ">> Creating index.js" url_base = "http://flightgear-gallery.googlecode.com/svn/trunk/v2.0" image_path = "v2.0/thumbs/" image_list = [] for img in os.listdir(image_path): if not img.startswith('.'): image_list.append( {'image': '%s/images...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import json print ">> Creating index.js" url_base = "http://flightgear-gallery.googlecode.com/svn/trunk/v2.0" image_path = "v2.0/thumbs/" image_list = [] for img in os.listdir(image_path): if not img.startswith('.'): image_list.append( {'image': '%s/images...
Python
import os import sys """ cachebuilder.py by Peter Balogh palexanderbalogh@yahoo.com to be used in conjunction with CacheBuilder.as part of a utility to a) load a large number of files into the browser cache, so that you can pre-load files for instant access later, and b) provide real, accurate feedback during th...
Python
from glob import glob filelist = [ i.split(".as")[0] for i in glob( "*.as" ) if i.find("ListOf") == -1 and i != "FunctionNode.as"] arraystring = '"' arraystring += '",\n \t\t"'.join( filelist ) print arraystring outfile = open("ListOfNodes.as", "w" ) outfile.write(""" /** * @author pbalogh */ class functionnod...
Python
from glob import glob filelist = [ i.split(".as")[0] for i in glob( "*.as" ) if i.find("ListOf") == -1 and i != "FunctionNode.as"] arraystring = '"' arraystring += '",\n \t\t"'.join( filelist ) print arraystring outfile = open("ListOfNodes.as", "w" ) outfile.write(""" /** * @author pbalogh */ package functions...
Python
#! /bin/env python ################################################################################### # # # Stitch v3.0, # # http://www.jportsmouth.com/code/Stitch/stitc...
Python
import urllib import cStringIO import Image import math def get_static_google_map(filename_wo_extension, center=None, zoom=None, imgsize="500x500", imgformat="jpeg", maptype="roadmap", markers=None ): """retrieve a map (image) from the static google maps server See: http://c...
Python
from pythonmap import * # Coordinates of center center = ("52.38","4.90") # Zoom level zoom = 12 # Size of returned map mapsize = (640,640) # Download and save map get_static_google_map("file_name", "%s,%s"%center, zoom, mapsize, imgformat="jpg", maptype="satellite") # Bounding box coordinates lowerRight = adjust(-m...
Python
# Collect Flickr Data with Python FlickrAPI # flickrapi path is required to be added to system path first # Scientific Visulization and Virtual Reality # Wouter Josemans and Ninghang Hu # Oct 21, 2010 import time import datetime import sys; sys.path.append('flickrapi-1.4.2./') import flickrapi sys.path.append('GetGoog...
Python
'''Persistent token cache management for the Flickr API''' import os.path import logging import time from flickrapi.exceptions import LockingError logging.basicConfig() LOG = logging.getLogger(__name__) LOG.setLevel(logging.INFO) __all__ = ('TokenCache', 'SimpleTokenCache') class SimpleTokenCache(object): '''...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- '''A FlickrAPI interface. The main functionality can be found in the `flickrapi.FlickrAPI` class. See `the FlickrAPI homepage`_ for more info. .. _`the FlickrAPI homepage`: http://stuvel.eu/projects/flickrapi ''' __version__ = '1.4.2' __all__ = ('FlickrAPI', 'IllegalAr...
Python
# -*- coding: utf-8 -*- '''Helper functions for the short http://fli.kr/p/... URL notation. Photo IDs can be converted to and from Base58 short IDs, and a short URL can be generated from a photo ID. The implementation of the encoding and decoding functions is based on the posts by stevefaeembra and Kohichi on http:/...
Python
'''Exceptions used by the FlickrAPI module.''' class IllegalArgumentException(ValueError): '''Raised when a method is passed an illegal argument. More specific details will be included in the exception message when thrown. ''' class FlickrError(Exception): '''Raised when a Flickr method fails...
Python
# -*- encoding: utf-8 -*- '''Module for encoding data as form-data/multipart''' import os import base64 class Part(object): '''A single part of the multipart data. >>> Part({'name': 'headline'}, 'Nice Photo') ... # doctest: +ELLIPSIS <flickrapi.multipart.Part object at 0x...> >>> image = op...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- '''A FlickrAPI interface. The main functionality can be found in the `flickrapi.FlickrAPI` class. See `the FlickrAPI homepage`_ for more info. .. _`the FlickrAPI homepage`: http://stuvel.eu/projects/flickrapi ''' __version__ = '1.4.2' __all__ = ('FlickrAPI', 'IllegalAr...
Python
# -*- encoding: utf-8 -*- '''HTTPHandler that supports a callback method for progress reports. ''' import urllib2 import httplib import logging __all__ = ['urlopen'] logging.basicConfig() LOG = logging.getLogger(__name__) progress_callback = None class ReportingSocket(object): '''Wrapper around a socket. Give...
Python
'''FlickrAPI uses its own in-memory XML representation, to be able to easily use the info returned from Flickr. There is no need to use this module directly, you'll get XMLNode instances from the FlickrAPI method calls. ''' import xml.dom.minidom __all__ = ('XMLNode', ) class XMLNode: """XMLNode -- generic cla...
Python
# -*- encoding: utf-8 -*- '''Call result cache. Designed to have the same interface as the `Django low-level cache API`_. Heavily inspired (read: mostly copied-and-pasted) from the Django framework - thanks to those guys for designing a simple and effective cache! .. _`Django low-level cache API`: http://www.djangop...
Python
#!/usr/bin/env python '''Python distutils install script. Run with "python setup.py install" to install FlickrAPI ''' import distribute_setup distribute_setup.use_setuptools() import sys # Check the Python version (major, minor) = sys.version_info[:2] if (major, minor) < (2, 4): raise SystemExit("Sorry, Pytho...
Python
#!/usr/bin/env python import tests tests.run_tests()
Python
#!python """Bootstrap distribute installation If you want to use setuptools in your package's setup.py, just include this file in the same directory with it, and add this to the top of your setup.py:: from distribute_setup import use_setuptools use_setuptools() If you want to require a specific version of se...
Python
# -*- encoding: utf-8 -*- '''The setup code is split into two sections, one in setup.py which contains very simple Python code and checks the Python version, and this file, which contains code only parsable by 2.4+. ''' __author__ = 'Sybren A. Stuvel' from setuptools import setup, Distribution import os import sys ...
Python
#!/usr/bin/env python '''Unittest for the FlickrAPI. Far from complete, but it's a start. ''' import logging import pkg_resources import StringIO import sys import types import unittest import urllib import urllib2 import webbrowser # Make sure the flickrapi module from the source distribution is used sys.path.inse...
Python