All Samples(319401) | Call(317453) | Derive(1945) | Import(3)
str(object) -> string Return a nice string representation of the object. If the argument is a string, the return value is the same object.
src/q/u/quickflash-HEAD/netcdf/examples/omega_analysis/generate_report.py quickflash(Download)
# Set up the command line parser
usage = str("%prog [ options ] input_files ...")
version = str("%prog 0.1")
argparser = OptionParser(usage, version=version)
use_ascii_data_str = str("use-ascii-data")
help="Use intermediate CSV files")
argparser.set_defaults(use_ascii_data=False)
omega_slicer_str = str("omega-slicer")
argparser.add_option("--" + omega_slicer_str, type="string",
dest="omega_slicer", help="omega_slicer executable")
argparser.set_defaults(omega_slicer=default_omega_slicer)
cross_resolution_str = str("cross-resolution")
help="Lateral resolution for slices")
argparser.set_defaults(cross_resolution=default_cross_resolution)
skip_images_str = str("skip-images")
argparser.add_option("--" + skip_images_str, action="store_true",
dest="skip_images", help="Do not convert ASCII data")
argparser.set_defaults(skip_images=False)
drawimage_str = str("drawimage")
help="drawimage program for converting CSV files")
argparser.set_defaults(drawimage=default_drawimage)
colormap_str = str("colormap")
argparser.add_option("--" + colormap_str, type="string",
dest="colormap", help="Colormap file for drawimage")
argparser.set_defaults(colormap=None)
skip_report_str = str("skip-report")
argparser.add_option("--" + skip_report_str, action="store_true",
dest="skip_report", help="Skip report generation")
argparser.set_defaults(skip_report=False)
skip_slicer_str = str("skip-slicer")
dest="skip_slicer", help="Skip omega_slicer")
argparser.set_defaults(skip_slicer=False)
output_path_str = str("output-path")
argparser.add_option("--" + output_path_str, type="string",
dest="output_path",
help="Directory path for output files")
argparser.set_defaults(output_path=None)
user_datasets_str = str("datasets")
slicer_options = filename \
+ " --output-prefix=" + current_output_prefix \
+ " --cross-resolution=" + str(cross_resolution)
if (not use_ascii_data) :
slicer_options += " --image-only"
src/q/u/quickflash-HEAD/netcdf/examples/flame_slicer/generate_report.py quickflash(Download)
# Set up the command line parser
usage = str("%prog [ options ] input_files ...")
version = str("%prog 0.1")
argparser = OptionParser(usage, version=version)
use_ascii_data_str = str("use-ascii-data")
help="Use intermediate CSV files")
argparser.set_defaults(use_ascii_data=False)
flame_slicer_str = str("flame-slicer")
argparser.add_option("--" + flame_slicer_str, type="string",
dest="flame_slicer", help="flame_slicer executable")
argparser.set_defaults(flame_slicer=default_flame_slicer)
cross_resolution_str = str("cross-resolution")
help="Lateral resolution for slices")
argparser.set_defaults(cross_resolution=default_cross_resolution)
skip_images_str = str("skip-images")
argparser.add_option("--" + skip_images_str, action="store_true",
dest="skip_images", help="Do not convert ASCII data")
argparser.set_defaults(skip_images=False)
drawimage_str = str("drawimage")
help="drawimage program for converting CSV files")
argparser.set_defaults(drawimage=default_drawimage)
colormap_str = str("colormap")
argparser.add_option("--" + colormap_str, type="string",
dest="colormap", help="Colormap file for drawimage")
argparser.set_defaults(colormap=None)
skip_report_str = str("skip-report")
argparser.add_option("--" + skip_report_str, action="store_true",
dest="skip_report", help="Skip report generation")
argparser.set_defaults(skip_report=False)
skip_slicer_str = str("skip-slicer")
dest="skip_slicer", help="Skip flame_slicer")
argparser.set_defaults(skip_slicer=False)
output_path_str = str("output-path")
argparser.add_option("--" + output_path_str, type="string",
dest="output_path",
help="Directory path for output files")
argparser.set_defaults(output_path=None)
user_datasets_str = str("datasets")
slicer_options = filename \
+ " --output-prefix=" + current_output_prefix \
+ " --cross-resolution=" + str(cross_resolution)
if (not use_ascii_data) :
slicer_options += " --image-only"
src/p/y/PyOFTK-HEAD/PyOFTK/examples/bragg_soliton_lin.py PyOFTK(Download)
elapsed = time.time() - t1
print "************ Simulation Parameters ************ "
print "Pulse Energy: " + str(pow(abs(pulse),2).sum()*dt) + " nJ"
print "FBG Length: " + str(fbg1.length) + " m"
print "Temporel iterations number: " + str(nt)
print "Total duration: " + str(nt*dt) + " ps"
print "Kappa: " + str(kapZero) + " [1/m]"
print "Gamma: " + str(gamma) + "m-1 W-1"
print "Detuning: " + str(detZero) + " [1/m]"
print "Detuning: " + str(1000*(LMBD-Longueur_onde_bragg)) + " [nm]"
print "Detuning: " + str(-((2.998e8)*1000*(LMBD-Longueur_onde_bragg))/(pow(LMBD*1000,2))) + " [GHz]"
print "Processing time: " + str(elapsed) + " secondes" + " (" + str(elapsed/60) + " minutes)"
src/p/y/PyOFTK-HEAD/PyOFTK/examples/bragg_soliton_cpu.py PyOFTK(Download)
elapsed = time.time() - t1
print "************ Simulation Parameters ************ "
print "Pulse Energy: " + str(pow(abs(pulse),2).sum()*dt) + " nJ"
print "FBG Length: " + str(fbg1.length) + " m"
print "Temporel iterations number: " + str(nt)
print "Total duration: " + str(nt*dt) + " ps"
print "Kappa: " + str(kapZero) + " [1/m]"
print "Gamma: " + str(gamma) + "m-1 W-1"
print "Detuning: " + str(detZero) + " [1/m]"
print "Detuning: " + str(1000*(LMBD-Longueur_onde_bragg)) + " [nm]"
print "Detuning: " + str(-((2.998e8)*1000*(LMBD-Longueur_onde_bragg))/(pow(LMBD*1000,2))) + " [GHz]"
print "Processing time: " + str(elapsed) + " secondes" + " (" + str(elapsed/60) + " minutes)"
src/p/y/PyOFTK-HEAD/PyOFTK/examples/bragg_soliton.py PyOFTK(Download)
elapsed = time.time() - t1
print "************ Simulation Parameters ************ "
print "Pulse Energy: " + str(pow(abs(pulse),2).sum()*dt) + " nJ"
print "FBG Length: " + str(fbg1.length) + " m"
print "Temporel iterations number: " + str(nt)
print "Total duration: " + str(nt*dt) + " ps"
print "Kappa: " + str(kapZero) + " [1/m]"
print "Gamma: " + str(gamma) + "m-1 W-1"
print "Detuning: " + str(detZero) + " [1/m]"
print "Detuning: " + str(1000*(LMBD-Longueur_onde_bragg)) + " [nm]"
print "Detuning: " + str(-((2.998e8)*1000*(LMBD-Longueur_onde_bragg))/(pow(LMBD*1000,2))) + " [GHz]"
print "Processing time: " + str(elapsed) + " secondes" + " (" + str(elapsed/60) + " minutes)"
src/p/y/python-oauth-HEAD/oauth/example/client.py python-oauth(Download)
def access_resource(self, oauth_request):
# via post body
# -> some protected resources
headers = {'Content-Type' :'application/x-www-form-urlencoded'}
self.connection.request('POST', RESOURCE_URL, body=oauth_request.to_postdata(), headers=headers)
response = self.connection.getresponse()
return response.read()
def run_example():
# setup
print '** OAuth Python Library Example **'
client = SimpleOAuthClient(SERVER, PORT, REQUEST_TOKEN_URL, ACCESS_TOKEN_URL, AUTHORIZATION_URL)
consumer = oauth.OAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET)
# get request token
print '* Obtain a request token ...'
pause()
oauth_request = oauth.OAuthRequest.from_consumer_and_token(consumer, callback=CALLBACK_URL, http_url=client.request_token_url)
oauth_request.sign_request(signature_method_plaintext, consumer, None)
print 'REQUEST (via headers)'
print 'parameters: %s' % str(oauth_request.parameters)
pause()
token = client.fetch_request_token(oauth_request)
print 'GOT'
print 'key: %s' % str(token.key)
print 'secret: %s' % str(token.secret)
print 'callback confirmed? %s' % str(token.callback_confirmed)
pause()
oauth_request = oauth.OAuthRequest.from_token_and_callback(token=token, http_url=client.authorization_url)
print 'REQUEST (via url query string)'
print 'parameters: %s' % str(oauth_request.parameters)
pause()
# this will actually occur only on some callback
response = client.authorize_token(oauth_request)
oauth_request = oauth.OAuthRequest.from_consumer_and_token(consumer, token=token, verifier=verifier, http_url=client.access_token_url)
oauth_request.sign_request(signature_method_plaintext, consumer, token)
print 'REQUEST (via headers)'
print 'parameters: %s' % str(oauth_request.parameters)
pause()
token = client.fetch_access_token(oauth_request)
print 'GOT'
print 'key: %s' % str(token.key)
print 'secret: %s' % str(token.secret)
print '* Access protected resources ...'
pause()
parameters = {'file': 'vacation.jpg', 'size': 'original'} # resource specific params
oauth_request = oauth.OAuthRequest.from_consumer_and_token(consumer, token=token, http_method='POST', http_url=RESOURCE_URL, parameters=parameters)
oauth_request.sign_request(signature_method_hmac_sha1, consumer, token)
print 'REQUEST (via post body)'
print 'parameters: %s' % str(oauth_request.parameters)
src/p/e/pexpect-HEAD/examples/monitor.py pexpect(Download)
try:
optlist, args = getopt.getopt(sys.argv[1:], 'h?s:u:p:', ['help','h','?'])
except Exception as e:
print(str(e))
exit_with_usage()
options = dict(optlist)
if len(args) > 1:
#
LOGFILE = open('monitor.log','wb')
child = pexpect.spawn('ssh -l %s %s'%(user, host),logfile=LOGFILE)
i = child.expect([pexpect.TIMEOUT, SSH_NEWKEY, COMMAND_PROMPT, '(?i)password: '])
if i == 0: # Timeout
print('ERROR! could not login with SSH. Here is what SSH said:')
print(child.before, child.after)
print(str(child))
child.sendline(password)
# Now we are either at the command prompt or
# the login process is asking for our terminal type.
i = child.expect ([COMMAND_PROMPT, TERMINAL_PROMPT, '(?i)password: '])
if i == 1:
child.sendline (TERMINAL_TYPE)
child.expect (COMMAND_PROMPT)
elif i == 2:
print('ERROR! could not login with SSH. Here is what SSH said:')
print(child.buffer)
print(str(child))
#
COMMAND_PROMPT = "\[PEXPECT\]\$ "
child.sendline ("PS1='[PEXPECT]\$ '") # In case of sh-style
i = child.expect ([pexpect.TIMEOUT, COMMAND_PROMPT], timeout=10)
if i == 0:
print("# Couldn't set sh-style prompt -- trying csh-style.")
child.sendline ("set prompt='[PEXPECT]\$ '")
i = child.expect ([pexpect.TIMEOUT, COMMAND_PROMPT], timeout=10)
# Run uname.
child.sendline ('uname -a')
child.expect (COMMAND_PROMPT)
print(child.before)
if 'linux' in child.before.lower():
LINUX_MODE = 1
mins = '0'
if 'day' in duration:
child.match = re.search('([0-9]+)\s+day',duration)
days = str(int(child.match.group(1)))
if ':' in duration:
child.match = re.search('([0-9]+):([0-9]+)',duration)
hours = str(int(child.match.group(1)))
mins = str(int(child.match.group(2)))
if 'min' in duration:
child.match = re.search('([0-9]+)\s+min',duration)
mins = str(int(child.match.group(1)))
print()
print('Uptime: %s days, %s users, %s (1 min), %s (5 min), %s (15 min)' % (
duration, users, av1, av5, av15))
child.expect (COMMAND_PROMPT)
# Run iostat.
child.sendline ('iostat')
child.expect (COMMAND_PROMPT)
print(child.before)
# Run vmstat.
child.sendline ('vmstat')
child.expect (COMMAND_PROMPT)
# Run free.
if LINUX_MODE:
child.sendline ('free') # Linux systems only.
child.expect (COMMAND_PROMPT)
print(child.before)
# Run df.
child.sendline ('df')
child.expect (COMMAND_PROMPT)
print(child.before)
# Run lsof.
child.sendline ('lsof')
child.expect (COMMAND_PROMPT)
try:
main()
except Exception as e:
print(str(e))
traceback.print_exc()
os._exit(1)
src/n/u/Numberjack-HEAD/examples/SendMoreMoney.py Numberjack(Download)
# Now Solve
out = ''
if solver.solve():
out += " " + str(s) + ' ' + str(e) + ' ' + str(n) + ' ' + str(d) + ' ' + '\n'
out += " + " + ' ' + str(m) + ' ' + str(o) + ' ' + str(r) + ' ' + str(e) + ' ' + '\n'
out += "= " + ' ' + str(m) + ' ' + str(o) + ' ' + str(n) + ' ' + str(e) + ' ' + str(y) + ' ' + '\n'
return out
src/p/y/pylon-HEAD/examples/national_grid/ngt.py pylon(Download)
DATA_DIR = "./data/"
BUS_DATA = [os.path.join(DATA_DIR, "spt_substations.csv"),
os.path.join(DATA_DIR, "shetl_substations.csv"),
os.path.join(DATA_DIR, "nget_substations.csv")
]
LOAD_DATA = [os.path.join(DATA_DIR, "demand_generation_pf-2009_10wp.csv"),
os.path.join(DATA_DIR, "demand_generation_pf-2009_10sop.csv")]
SHUNT_DATA = [os.path.join(DATA_DIR, "spt_shunt_data.csv"),
os.path.join(DATA_DIR, "shetl_shunt_data.csv"),
os.path.join(DATA_DIR, "nget_shunt_data.csv")
]
BRANCH_DATA = [
os.path.join(DATA_DIR, "spt_circuit_param.csv"),
os.path.join(DATA_DIR, "shetl_circuit_param.csv"),
os.path.join(DATA_DIR, "nget_circuit_param.csv")
]
TRANSFORMER_DATA = [os.path.join(DATA_DIR, "spt_transformer_details.csv"),
os.path.join(DATA_DIR, "shetl_transformer_details.csv"),
os.path.join(DATA_DIR, "nget_transformer_details.csv")
]
GENERATOR_DATA = [os.path.join(DATA_DIR, "generator_unit_data.csv")]
for row in bus_reader:
assert int(row[2]) in [400, 275, 132, 66, 33, 11]
if row[2] == str(voltage):
name = row[1]
assert len(name) == 4
node_id = row[6]
if len(node_id):
if node_id[4] == str(voltage)[0]:
if bus_map.has_key(node_id[:4]):
node = bus_map[node_id[:4]]
else:
# else:
# print "No voltage entry for shunt.", row[0], row[1][4]
if row[1][4] == str(voltage)[0]:
try:
node = bus_map[row[1][:4]]
except KeyError:
n2_id = row[1]
# Ignore branches of other voltages (according to 5th digit).
if row[0][4] != str(voltage)[0]:
# print "skipping:", row[0][4], str(voltage)[0] + ", ".join(row)
continue
# else:
# print "No Bus: " + ", ".join(row)
continue
if row[9][4] == str(voltage)[0] and row[11] == licensee:
node_id = row[9]
try:
src/q/u/quickflash-HEAD/trunk/examples/raytracer/drawimage.py quickflash(Download)
numeric_float = Numeric.Float
png_suffix = str(".png")
csv_suffix = str(".csv")
for m in range(m_size) :
for n in range(n_size) :
output.write(str(data[m][n]) + " ")
output.write("\n")
# Set up the command line parser
usage = str("%prog input_file [options]")
version = str("%prog 0.1")
argparser = OptionParser(usage, version=version)
output_prefix_str = str("output-prefix")
argparser.add_option("--" + output_prefix_str, type="string",
dest="output_prefix", help="Output file prefix")
argparser.set_defaults(output_prefix=None)
min_value_str = str("min-value")
dest="min_value", help="Image minimum data value")
argparser.set_defaults(min_value=None)
max_value_str = str("max-value")
argparser.add_option("--" + max_value_str, type="float",
dest="max_value", help="Image maximum data value")
argparser.set_defaults(max_value=None)
compute_symmetry_str = str("compute-symmetry")
help="Specify symmetry axis (0 or 1)")
argparser.set_defaults(symmetry_axis=None)
write_data_str = str("write-data")
argparser.add_option("--" + write_data_str, action="store_true",
dest="write_data",
help="Write ASCII data instead of image")
argptr = int(0)
input_file = str(args[argptr])
argptr += 1
if ((min_value is not None) and (max_value is not None)) :
if (not (min_value < max_value)) :
stderr.write("Error: Min value [ " + str(min_value)
+ " ] must be less than max [ " + str(max_value)
+ " ]\n\n")
exit(-1)
sum_file_comment = "Sum data from file [ " + input_file \
+ " ] with symmetry axis [ " \
+ str(symmetry_axis) + " ]"
diff_file_comment = "Difference data from file [ " + input_file \
+ " ] with symmetry axis [ " \
+ str(symmetry_axis) + " ]"
Previous 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 Next