Ejemplo n.º 1
0
 def runChaco(self, nProcs) :
     paramsFile = file('User_Params', 'w')
     paramsFile.write('OUTPUT_ASSIGN=true\n')
     paramsFile.write('PROMPT=false\n')
     paramsFile.write('ARCHITECTURE=1\n')
     paramsFile.write('REFINE_PARTITION=4\n')
     paramsFile.write('REFINE_MAP=true\n')
     paramsFile.write('KL_BAD_MOVES=20\n')
     paramsFile.write('KL_NTRIES_BAD=10\n')
     paramsFile.write('KL_IMBALANCE=0.02\n')
     paramsFile.write('INTERNAL_VERTICES=true\n')
     paramsFile.write('MATCH_TYPE=2\n')
     paramsFile.write('HEAVY_MATCH=true\n')
     paramsFile.write('TERM_PROP=true\n')
     paramsFile.write('COARSE_NLEVEL_KL=1\n')
     paramsFile.write('COARSEN_RATIO_MIN=0.7\n')
     paramsFile.write('CUT_TO_HOP_COST=1.0\n')
     paramsFile.write('RANDOM_SEED=12345\n')
     paramsFile.flush()
     inputFile = file('chacoInput', 'w')
     inputFile.write('%s.graph\n' % self.filename_)
     inputFile.write('%s.assign\n' % self.filename_)
     inputFile.write('1\n')    # select partitioning algorithm. 1=multilevel
     inputFile.write('100\n')  # num vertices in coarsest graph
     inputFile.write('%d\n' % nProcs) # number of partitions
     inputFile.write('1\n') # apply bisection
     inputFile.write('n\n') # answer 'n' to query about running another problem
     inputFile.flush()
     inputFile.close()
     print 'calling Chaco'
     posix.system('chaco < chacoInput')
Ejemplo n.º 2
0
def main():
  for filename in ('/etc/passwd', 'etc/passwd.bak'):
    try:
      users, table = userinfo(filename)
      print table.keys()[3:7], table['postgres']
      posix.system('ls -al ' + filename)
    except:
      print 'File "' + filename + '" not found!'
Ejemplo n.º 3
0
 def invoke (self, terms):
     command = re.sub("%T", terms, self.argument);
     command = re.sub("%U", urllib.quote(terms), command);
     if (self.type == self.EXEC):
         posix.system(command)
     else:
         # gnome.url_show(command)
         posix.system("gnome-mozilla '%s'" % command)
Ejemplo n.º 4
0
 def on_bprint_clicked(self, widget, data=None):
   filename = self.wTree.fileentry.get_text()
   dirname = self.wTree.direntry.get_text()
   if (filename == ""): filename = "blank"
   filename = "tmp#" + filename + ".png"
   self.wTree.plot.save(filename)
   posix.system("png_printer.sh " + filename)
   return
Ejemplo n.º 5
0
 def on_bblog_clicked(self, widget, data=None):
   filename = self.wTree.fileentry.get_text()
   dirname = self.wTree.direntry.get_text()
   if (dirname == ""): dirname = "."  
   if (filename == ""): filename = "blank"
   filename = dirname+"/"+filename
   self.wTree.plot.save("#screenimage#")
   posix.system("daq_blogger.sh " + filename)
   return
Ejemplo n.º 6
0
 def on_bsave_clicked(self, widget, data=None):
   filename = self.wTree.fileentry.get_text()
   dirname = self.wTree.direntry.get_text()
   if (dirname == ""): dirname = "."
   if (filename == ""): filename = "blank"
   filename = dirname+"/"+filename+".png"
   self.wTree.plot.save("#screenimage#")
   posix.system('mv \#screenimage\# ' + filename)
   return
Ejemplo n.º 7
0
def clearcache():
	for x in cache.keys():
		try:
			sts = posix.system('rm -f ' + cache[x])
			if sts:
				print cmd
				print 'Exit status', sts
		except:
			print cmd
			print 'Exception?!'
		del cache[x]
Ejemplo n.º 8
0
def Main():
    form = cgi.FieldStorage()

    if not form.has_key("recipient"):
        style.SendError("Enter Sender")
    if not form.has_key("email"):
        style.SendError("Enter your email address")
    if not form.has_key("subject"):
        style.SendError("Enter Subject")

    real_recipient = form["recipient"].value
    real_name = form["name"].value
    real_email = form["email"].value
    real_subject = form["subject"].value
    real_content = form["content"].value

    # Format the Content of the Email
    mailsender = "Sent from our website by:\n"
    mailsender = mailsender + real_name
    mailbreak = "\n---------------------------------\n"
    mailfrom = "Senders address:\n"
    mailfrom = mailfrom + real_email
    mailcontent = "Content:\n"
    mailcontent = mailcontent + real_content

    mailstring = mailsender + mailbreak + mailfrom + mailbreak + mailcontent + mailbreak

    sysstring = 'echo "' + mailstring + '"  | mail -s "' + real_subject + '" "' + real_recipient + '"'
    posix.system(sysstring)

    style.header("Email Successfully Sent!", "/images/ISU_bkgrnd.gif")
    style.std_top("Sent email")
    print '<a href="http://www.pals.iastate.edu/home/email.html">Send another Email</a>--'
    print '<a href="http://www.pals.iastate.edu">GO to PALS Homepage</a>'
    print "<HR>\n"
    print "<center>"
    print "<H1>Email Sent to:</H1>\n"
    print real_recipient
    print "<br><BR><BR><BR><BR><BR>"
    style.std_bot()
Ejemplo n.º 9
0
def runChaco(graphFile, nProcs) :
    paramsFile = file('User_Params', 'w')
    paramsFile.write('OUTPUT_ASSIGN=true\n')
    paramsFile.write('PROMPT=false\n')
    paramsFile.write('ARCHITECTURE=1\n')
    paramsFile.write('REFINE_PARTITION=4\n')
    paramsFile.write('INTERNAL_VERTICES=true\n')
    paramsFile.write('MATCH_TYPE=4\n')
    paramsFile.write('COARSE_NLEVEL_KL=1\n')
    paramsFile.write('CUT_TO_HOP_COST=1.0\n')
    paramsFile.flush()
    inputFile = file('chacoInput', 'w')
    inputFile.write('%s.graph\n' % graphFile)
    inputFile.write('%s.assign\n' % graphFile)
    inputFile.write('1\n')
    inputFile.write('400\n')
    inputFile.write('%d\n' % nProcs)
    inputFile.write('1\n')
    inputFile.write('n\n')
    inputFile.flush()
    inputFile.close()
    posix.system('chaco < chacoInput')
Ejemplo n.º 10
0
def playfile(name):
	if G.mode <> 'mac':
		tempname = name
	elif cache.has_key(name):
		tempname = cache[name]
	else:
		tempname = G.tempprefix + `rand.rand()`
		cmd = HOME_BIN_SGI + 'macsound2sgi'
		cmd = cmd + ' ' + commands.mkarg(name)
		cmd = cmd + ' >' + tempname
		if G.debug: print cmd
		sts = posix.system(cmd)
		if sts:
			print cmd
			print 'Exit status', sts
			stdwin.fleep()
			return
		cache[name] = tempname
	fp = open(tempname, 'r')
	try:
		hdr = sunaudio.gethdr(fp)
	except sunaudio.error, msg:
		hdr = ()
Ejemplo n.º 11
0
 def runMetis(self, nProcs):
     posix.system("kmetis %s.graph %d" % (self.filename_, nProcs))
     posix.system("cp %s.graph.part.%d %s.assign" % (self.filename_, nProcs, self.filename_))
Ejemplo n.º 12
0
# Now use our plotting widget

import posix
import sys
import string
from plotwidget import *
from math import *

line = raw_input("Enter a function of x : ")
ranges = string.split(raw_input("Enter xmin,ymin,xmax,ymax :"),",")

print "Making a plot..."

w = PlotWidget(500,500,string.atof(ranges[0]),string.atof(ranges[1]),
               string.atof(ranges[2]),string.atof(ranges[3]))


code = "def func(x): return " + line
exec(code)

w.set_pymethod(func)
w.plot()

f = open("plot.gif","w")
w.save(f)
f.close()
posix.system("xv plot.gif &")



Ejemplo n.º 13
0
def ps():
    posix.system('ps -l | grep python | grep -v grep')
Ejemplo n.º 14
0
# Now use our plotting widget

import posix
import sys
import string
from plotwidget import *
from math import *

line = raw_input("Enter a function of x : ")
ranges = string.split(raw_input("Enter xmin,ymin,xmax,ymax :"), ",")

print "Making a plot..."

w = PlotWidget(500, 500, string.atof(ranges[0]), string.atof(ranges[1]),
               string.atof(ranges[2]), string.atof(ranges[3]))

code = "def func(x): return " + line
exec(code)

w.set_pymethod(func)
w.plot()

f = open("plot.gif", "w")
w.save(f)
f.close()
posix.system("xv plot.gif &")
Ejemplo n.º 15
0
def Main(userKey, caseNum, forecast_pts, bonus_pts, className):

	userKey, lastTime, gradeTime, startTime, noonTime, endTime, caseNum, className = functs.retreiveUser()
	
	name = advdb.query("SELECT name, email from users WHERE userKey = '"+str(userKey)+"' ").dictresult()
	subject = "Adv SxFrcst output for "+name[0]["name"]

	try:
		remoteHost = os.environ["REMOTE_HOST"]
	except:
		remoteHost = "NATF"

	nowDate = mx.DateTime.now()
	startDate = mx.DateTime.localtime( int(float(userKey)) )
	endDate = mx.DateTime.ISO.ParseDateTimeGMT(endTime)
	now_date = nowDate.strftime("%x %I:%M %p")
	start_date = startDate.strftime("%x %I:%M %p")
	str_date = endDate.strftime("%x %I Z")

	mailstring =              "**** On-Line Forecasting Exercise Results **** \n"
	mailstring = mailstring + "Case Number        => "+caseNum+" \n"
	mailstring = mailstring + "Case End Date      => "+str_date+" \n"
	mailstring = mailstring + "Student Name       => "+name[0]["name"]+" \n"
	mailstring = mailstring + "Student Email      => "+name[0]["email"]+" \n"
	mailstring = mailstring + "Student Started At => "+start_date+" \n"
	mailstring = mailstring + "Student Finished At=> "+now_date+" \n"
	mailstring = mailstring + "Class of Student   => "+className+" \n"
	mailstring = mailstring + "IP of Remote Host => "+remoteHost+" \n"
	mailstring = mailstring + "********************************************** \n\n"
	
	mailstring = mailstring + "**** Points earned from automatic Grading **** \n"
	mailstring = mailstring + "Forecasting Points => "+forecast_pts+"\n"
	mailstring = mailstring + "Bonus Points       => "+bonus_pts+"\n"
	mailstring = mailstring + "********************************************** \n\n"

	forecasts = advdb.query("SELECT etime, state, optiona, optionb, optionc, optiond from users WHERE userKey = '"+str(userKey)+"' ").getresult()
	mailstring = mailstring + "****         The Students Forecast        **** \n"
	mailstring = mailstring + "Forecasted State  => "+forecasts[0][1]+"\n"
	if caseNum[0] == 's':
		mailstring = mailstring + "Forecasted Time   => "+forecasts[0][0]+"\n"
		mailstring = mailstring + "Heavy Rainfall    => "+forecasts[0][2]+"\n"
		mailstring = mailstring + "Tornado           => "+forecasts[0][3]+"\n"
		mailstring = mailstring + "Hail              => "+forecasts[0][4]+"\n"
	elif caseNum[0] == 'w':
		mailstring = mailstring + "Six Inch Snowfall => "+forecasts[0][2]+"\n"
		mailstring = mailstring + "Twelve Inch Snow  => "+forecasts[0][3]+"\n"
		mailstring = mailstring + "Freezing Rainfall => "+forecasts[0][4]+"\n"
		mailstring = mailstring + "Wind Chill        => "+forecasts[0][5]+"\n"
	mailstring = mailstring + "********************************************** \n\n"

	sections = tmpdb.query("SELECT * from s"+str(userKey)+" ").dictresult()
	mailstring = mailstring + "*****   Answers to individual questions  ***** \n"
	for i in range(len(sections)):
		q_id = sections[i]["ticks"]
		question = sections[i]["question"]
		theirAnswer = sections[i]["answer"]
		correctAnswer = sections[i]["cor_answer"]
		theirAnswer = regsub.gsub("&#180;", "'", theirAnswer)

		if len(theirAnswer) > 1 or correctAnswer == 'T': # We have a text question
			mailstring = mailstring +" \n Question "+q_id+": \n \t "+question+" \n \n "+name[0]["name"]+" Replied: \n \t "+theirAnswer+" \n"

		else:	# We have a multiple choice
			guessOption= "option"+string.lower(theirAnswer[0][0])
			answerOption = "option"+string.lower(correctAnswer[0][0])
			
			guessTxt = advdb.query("SELECT "+guessOption+" from questions WHERE q_id = '"+q_id+"' ").getresult()
			if len(guessTxt) == 0:
					guessTxt = advdb.query("SELECT "+guessOption+" from questions_custom WHERE className = '"+className+"' and validTime = '"+q_id+"' ").getresult()
			answerTxt = advdb.query("SELECT "+answerOption+" from questions WHERE q_id = '"+q_id+"' ").getresult()
			if len(answerTxt) == 0:
					answerTxt = advdb.query("SELECT "+answerOption+" from questions_custom WHERE className = '"+className+"' and validTime = '"+q_id+"' ").getresult()

			mailstring = mailstring +" \n Question "+q_id+": \n \t "+question+" \n \n "+name[0]["name"]+" Replied: \n \t "+string.upper(theirAnswer)+". "+guessTxt[0][0]+"\n"
			mailstring = mailstring +"\n The Correct Answer was: \n \t "+correctAnswer[0][0]+". "+answerTxt[0][0]+" \n"

		mailstring = mailstring +"-------------------------------------------------------------------------------"
	
	instructorEmail =advdb.query("SELECT instructor_email from classes WHERE class_abv = '"+className+"' ").getresult()[0][0]

	sysstring = 'echo "' + mailstring+ '"  | mail -s "'+subject+'" "'+SENDTO+'"'
	posix.system(sysstring)

	sysstring = 'echo "' + mailstring+ '"  | mail -s "'+subject+'" "'+instructorEmail+'"'
	posix.system(sysstring)
Ejemplo n.º 16
0
# $Id: addPyGistTracker.py,v 1.1 2009/11/19 23:44:45 dave Exp $
#  -----------------------------------------------------------------
#  LLNL-specific file
#  -----------------------------------------------------------------

from posix import system
try:
   system ( "/usr/apps/tracker/bin/tracker -s -n PYGIST -v %s" % __version__ )
except:
   pass
Ejemplo n.º 17
0
Archivo: plot.py Proyecto: gitpan/swig
def func1(x):
    return 0.5 * sin(x) + 0.25 * sin(2 * x) + 0.125 * cos(4 * x)


print "Making plot1.gif..."
# Make a widget and set callback
w = PlotWidget(500, 500, -10, -2, 10, 2)
w.set_pymethod(func1)
w.plot()
f = open("plot1.gif", "w")
w.save(f)
f.close()

# Comment this line out if you don't have xv
posix.system("xv plot1.gif &")

# Make another plot

print "Making plot2.gif..."
w1 = PlotWidget(500, 500, -4, -1, 4, 16)
w1.set_pymethod(lambda x: x * x)
w1.plot()
f = open("plot2.gif", "w")
w1.save(f)
f.close()

posix.system("xv plot2.gif &")

# Make yet another plot
Ejemplo n.º 18
0
 qdevice(MOUSE2)         # Middle button
 unqdevice(INPUTCHANGE)
 #
 lasttime = 0
 Gl.change = 1
 while 1:
         if realtime:
                 localtime = time.time() - Gl.tzdiff
         if Gl.alarm_set:
                 if localtime%(24*HOUR) = Gl.alarm_time:
                         # Ring the alarm!
                         if Gl.debug:
                                 print 'Rrrringg!'
                         Gl.alarm_on = 1
                         if Gl.alarm_cmd <> '':
                                 d = posix.system(Gl.alarm_cmd+' '+`Gl.alarm_time/3600`+' '+`(Gl.alarm_time/60)%60` + ' &')
                         Gl.change = 1
                         clearall()
         if Gl.alarm_on:
                 if (localtime - Gl.alarm_time) % (24*HOUR) > 300:
                         # More than 5 minutes away from alarm
                         Gl.alarm_on = 0
                         if Gl.debug:
                                 print 'Alarm turned off'
                         Gl.change = 1
                         clearall()
                         Gl.indices = R, G, B
                 else:
                         if localtime % 2 = 0:
                           # Permute color indices
                           Gl.indices = Gl.indices[2:] + Gl.indices[:2]
Ejemplo n.º 19
0
def ncdf2tri(filename) :
    cmd = './Exo2Triangle.exe --i=%s.ncdf --o=%s' % (filename, filename)
    posix.system(cmd)
Ejemplo n.º 20
0
def ncdf2tri(filename):
    cmd = './Exo2Triangle.exe --i=%s.ncdf --o=%s' % (filename, filename)
    posix.system(cmd)
Ejemplo n.º 21
0
from posix import system

BASE_URL = 'https://github.com/rcore-os/rCore_tutorial/tree/'

for line in open('commit_ids.txt').readlines():
    path, commit_id = line[:-1].split(': ')
    path = path + '.md'
    find = r'^\[CODE\].*'
    replace = '[CODE]: {}{}'.format(BASE_URL, commit_id)
    system("sed -i '' -E 's#{}#{}#g' {}".format(find, replace, path))
Ejemplo n.º 22
0
Archivo: plot.py Proyecto: gitpan/swig
from math import *

def func1(x):
	return 0.5*sin(x)+0.25*sin(2*x)+0.125*cos(4*x)

print "Making plot1.gif..."
# Make a widget and set callback
w = PlotWidget(500,500,-10,-2,10,2)
w.set_pymethod(func1)
w.plot()
f = open("plot1.gif","w")
w.save(f)
f.close()

# Comment this line out if you don't have xv
posix.system("xv plot1.gif &")

# Make another plot

print "Making plot2.gif..."
w1 = PlotWidget(500,500,-4,-1,4,16)
w1.set_pymethod(lambda x: x*x)
w1.plot()
f = open("plot2.gif","w")
w1.save(f)
f.close()

posix.system("xv plot2.gif &")

# Make yet another plot
Ejemplo n.º 23
0
Here is the vegetation albedo in vegetation.h
"""
import sys
import os
from posix import system

#values to cycle
Pressures = [0.5, 1., 1.5]  #times the Earth value

#simtype, version, simulation number
simtype = "Std"
version = "1.1.02"
number = 1

# multiple output directory preparation
system("mkdir -p RisultatiMultipli")
system("mkdir -p Database")
system("cp -r CCM_RH60 Src")

for p in Pressures:

    # preparing Src (usually done by run.bash)
    system("cp ModulesDef/* Src")
    system("cp Std/* Src")
    if simtype == "VegPassive":
        system("cp VegPassive/* Src")
        system("cp= VegPassive/Modules/* Src")
    elif simtype == "VegAlbedoFB":
        system("cp VegAlbedoFB/* Src")
        system("cp VegAlbedoFB/Modules/* Src")
Ejemplo n.º 24
0
   	 iCF += 1
      if exit==0:
   	 pl=pl+'\n'
   	 pl=pl+'     >     ' 
   pf.write(pl)
   
tf.close()
pf.close()
   
   #print TOLR
   #print vOLR
   
print 'updated parameter file parEBM.h'
   
from posix import system
system('make')
   
print 'linked codeEBM.x'
   
system('./codeEBM.x')
   
   
   
   

   
   
   

   
   
Ejemplo n.º 25
0
	def kill(self, selected):
		c = self.format_list[self.format.get()][2]
		pid = split(selected)[c]
		posix.system('kill' + ' -9 ' + pid)
		self.do_update()
Ejemplo n.º 26
0
def exo2ncdf(filename):
    cmd = 'ncdump %s.exo > %s.ncdf' % (filename, filename)
    posix.system(cmd)
Ejemplo n.º 27
0
 def runMetis(self, nProcs):
     posix.system('kmetis %s.graph %d' % (self.filename_, nProcs))
     posix.system('cp %s.graph.part.%d %s.assign' %
                  (self.filename_, nProcs, self.filename_))
Ejemplo n.º 28
0
## Automatically adapted for numpy Jul 30, 2006 by numeric2numpy.py

# $Id: addPyGistTracker.py 598 2006-12-13 11:12:09Z mbec $
#  -----------------------------------------------------------------
#  LLNL-specific file
#  -----------------------------------------------------------------

from posix import system
try:
    system("/usr/apps/tracker/bin/tracker -s -n PYGIST -v %s" % __version__)
except:
    pass
Ejemplo n.º 29
0
def exo2ncdf(filename) :
    cmd = 'ncdump %s.exo > %s.ncdf' % (filename, filename)
    posix.system(cmd)
Ejemplo n.º 30
0
	       '</a></li>')
print '</ul></div>'

print '''
<p style="float:right; text-align:right; font-size: small">
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.5/ca/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-sa/2.5/ca/88x31.png" /></a><br /><span xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://purl.org/dc/dcmitype/Text" property="dc:title" rel="dc:type">Licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.5/ca/">Creative Commons<br />Attribution-Noncommercial-Share<br />Alike 2.5 Canada License</a>.
</p>
<p style="page-break-after:always">
&nbsp;<br />
<em>Produced by <strong>Emanuel Borsboom</strong>
<br />Mayne Island, B.C.
<br />web: <a href="https://borsboom.io/">borsboom.io</a></em>
</p>
<p class="printonly" style="page-break-after:always;text-align:center">(this page intentionally left blank)</p>
'''

for month in range(1,13):
	print ('<h3 style="margin-bottom:4pt;page-break-before:always"><a name="' + ('%02d' % month) + '" />' + 
    	   time.strftime('%B, %Y', time.localtime(time.mktime((year,month,1,0,0,0,0,0,0)))) +
	       '<span class="printonly" style="float:right;font-size:smaller">Current Atlas Lookup Tables: Juan de Fuca Strait to Strait of Georgia</span>' +
	       '</h3><center>&nbsp;<br />')
	sys.stdout.flush()
	posix.system('tide -l "Point Atkinson, British Columbia" -f c -b "' +
			     time.strftime('%Y-%m-%d %H:%M', time.localtime(time.mktime((year,month,0,12,0,0,0,0,0)))) +
			     '" -e "' +
			     time.strftime('%Y-%m-%d %H:%M', time.localtime(time.mktime((year,month+1,1,12,0,0,0,0,0)))) +
			     '" | ./calculate.py --time-interval 60 | ./format.py --html --header-time-format "%H" --time-format "%H%M" --date-format \'%d<br /><span class="ca_span_dayofweek">%a</span>\' --deviations')
	print '</center>'

print '</body></html>'
Ejemplo n.º 31
0
import os
import posix

path = "."

my_list = os.listdir(path)

for file_name in my_list:
    if 'java' in file_name.split('.'):
        command_string = 'j2py -i '+file_name+' -o '+file_name.split('.')[0]+'.py'
        print command_string
        posix.system(command_string)
    else:
        print 'not java file' 
Ejemplo n.º 32
0
        dataX.append(float(dataItem))

    dataY = []
    for dataItem in Y:
        dataY.append(float(dataItem))

    dataF = []
    for dataItem in frequency:
        dataF.append(float(dataItem))

    # Calculate power X^2 + Y^2
    j = 0
    power = []
    for item in dataX:
        power.append(ASF * ASF * item * item + dataY[j] * dataY[j])
        j = j + 1

    # save [frequency power] for xmgr plotting/fitting
    powerfile = "./junkPower_" + thisStepNumberS
    n = len(frequency)
    fd = open(powerfile, "w")
    for i in range(n - 1):
        print >> fd, frequency[i] / FSF, power[i]
    fd.close()


# Write to files, cleaup
system("cat junkXY* > " + filenameS + "_" + str(startFreq) + "-" + str(stopFreq) + "Hz")
system("cat junkPower* > power" + filenameS + "_" + str(startFreq) + "-" + str(stopFreq) + "Hz")
system("rm junk*")