Related
Code to extract sequences
from Bio import SeqIO
def get_cds_feature_with_qualifier_value(seq_record, name, value):
for feature in genome_record.features:
if feature.type == "CDS" and value in feature.qualifiers.get(name, []):
return feature
return None
genome_record = SeqIO.read("470.8208.gbk", "genbank")
db_xref = ['fig|470.8208.peg.2198', 'fig|470.8208.peg.2200', 'fig|470.8208.peg.2203', 'fig|470.8208.peg.2199', 'fig|470.8208.peg.2201', 'fig|470.8208.peg.2197', 'fig|470.8208.peg.2202', 'fig|470.8208.peg.2501', 'fig|470.8208.peg.2643', 'fig|470.8208.peg.2193', 'fig|470.8208.peg.2670', 'fig|470.8208.peg.2695', 'fig|470.8208.peg.2696', 'fig|470.8208.peg.2189', 'fig|470.8208.peg.2458', 'fig|470.8208.peg.2191', 'fig|470.8208.peg.2190', 'fig|470.8208.peg.2188', 'fig|470.8208.peg.2192', 'fig|470.8208.peg.2639', 'fig|470.8208.peg.3215', 'fig|470.8208.peg.2633', 'fig|470.8208.peg.2682', 'fig|470.8208.peg.3186', 'fig|470.8208.peg.2632', 'fig|470.8208.peg.2683', 'fig|470.8208.peg.3187', 'fig|470.8208.peg.2764', 'fig|470.8208.peg.2686', 'fig|470.8208.peg.2638', 'fig|470.8208.peg.2680', 'fig|470.8208.peg.2685', 'fig|470.8208.peg.2684', 'fig|470.8208.peg.2633', 'fig|470.8208.peg.2682', 'fig|470.8208.peg.3186', 'fig|470.8208.peg.2632', 'fig|470.8208.peg.2683', 'fig|470.8208.peg.3187', 'fig|470.8208.peg.2640', 'fig|470.8208.peg.3221', 'fig|470.8208.peg.3222', 'fig|470.8208.peg.3389', 'fig|470.8208.peg.2764', 'fig|470.8208.peg.2653', 'fig|470.8208.peg.3216', 'fig|470.8208.peg.3231', 'fig|470.8208.peg.2641', 'fig|470.8208.peg.2638', 'fig|470.8208.peg.2680', 'fig|470.8208.peg.2637', 'fig|470.8208.peg.2642', 'fig|470.8208.peg.2679', 'fig|470.8208.peg.3230', 'fig|470.8208.peg.2676', 'fig|470.8208.peg.2677', 'fig|470.8208.peg.1238', 'fig|470.8208.peg.2478', 'fig|470.8208.peg.2639', 'fig|470.8208.peg.854', 'fig|470.8208.peg.382', 'fig|470.8208.peg.383']
with open("nucleotides.fasta", "w") as nt_output, open("proteins.fasta", "w") as aa_output:
for xref in db_xref:
print ("Looking at " + xref)
cds_feature = get_cds_feature_with_qualifier_value (genome_record, "db_xref", xref)
gene_sequence = cds_feature.extract(genome_record.seq)
protein_sequence = gene_sequence.translate(table=11, cds=True)
# This is asking Python to halt if the translation does not match:
assert protein_sequence == cds_feature.qualifiers["translation"][0]
# Output FASTA records - note \n means insert a new line.
# This is a little lazy as it won't line wrap the sequence:
nt_output.write(">%s\n%s\n" % (xref, gene_sequence))
aa_output.write(">%s\n%s\n" % (xref, gene_sequence))
print("Done")
getting following error
/usr/local/lib/python3.7/dist-packages/Bio/GenBank/Scanner.py:1394: BiopythonParserWarning: Truncated LOCUS line found - is this correct?
:'LOCUS CP027704 3430798 bp DNA linear UNK \n'
BiopythonParserWarning,
Looking at fig|470.8208.peg.2198
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-32-323ff320990a> in <module>()
15 print ("Looking at " + xref)
16 cds_feature = get_cds_feature_with_qualifier_value (genome_record, "db_xref", xref)
---> 17 gene_sequence = cds_feature.extract(genome_record.seq)
18 protein_sequence = gene_sequence.translate(table=11, cds=True)
19
AttributeError: 'NoneType' object has no attribute 'extract'
You have a space between the get_cds_feature_with_qualifier_value call and its parameters (genome_record, "db_xref", xref), so the call is probably failing, leaving cds_feature as None.
Generally, you should provide reproducible examples so that someone else (who doesn't have the gbk file you're referencing) can still reproduce and troubleshoot your error.
Solved the problem.
'''
from Bio import SeqIO
def get_cds_feature_with_qualifier_value(seq_record, name, value):
for feature in genome_record.features:
if feature.type == "CDS" and value in feature.qualifiers.get(name, []):
return feature
return None
genome_record = SeqIO.read("470.8208.gbk", "genbank")
da_xref = ['fig|470.8208.peg.2198', 'fig|470.8208.peg.2200', 'fig|470.8208.peg.2203', 'fig|470.8208.peg.2199', 'fig|470.8208.peg.2201', 'fig|470.8208.peg.2197', 'fig|470.8208.peg.2202', 'fig|470.8208.peg.2501', 'fig|470.8208.peg.2643', 'fig|470.8208.peg.2193', 'fig|470.8208.peg.2670', 'fig|470.8208.peg.2695', 'fig|470.8208.peg.2696', 'fig|470.8208.peg.2189', 'fig|470.8208.peg.2458', 'fig|470.8208.peg.2191', 'fig|470.8208.peg.2190', 'fig|470.8208.peg.2188', 'fig|470.8208.peg.2192', 'fig|470.8208.peg.2639', 'fig|470.8208.peg.3215', 'fig|470.8208.peg.2633', 'fig|470.8208.peg.2682', 'fig|470.8208.peg.3186', 'fig|470.8208.peg.2632', 'fig|470.8208.peg.2683', 'fig|470.8208.peg.3187', 'fig|470.8208.peg.2764', 'fig|470.8208.peg.2686', 'fig|470.8208.peg.2638', 'fig|470.8208.peg.2680', 'fig|470.8208.peg.2685', 'fig|470.8208.peg.2684', 'fig|470.8208.peg.2633', 'fig|470.8208.peg.2682', 'fig|470.8208.peg.3186', 'fig|470.8208.peg.2632', 'fig|470.8208.peg.2683', 'fig|470.8208.peg.3187', 'fig|470.8208.peg.2640', 'fig|470.8208.peg.3221', 'fig|470.8208.peg.3222', 'fig|470.8208.peg.3389', 'fig|470.8208.peg.2764', 'fig|470.8208.peg.2653', 'fig|470.8208.peg.3216', 'fig|470.8208.peg.3231', 'fig|470.8208.peg.2641', 'fig|470.8208.peg.2638', 'fig|470.8208.peg.2680', 'fig|470.8208.peg.2637', 'fig|470.8208.peg.2642', 'fig|470.8208.peg.2679', 'fig|470.8208.peg.3230', 'fig|470.8208.peg.2676', 'fig|470.8208.peg.2677', 'fig|470.8208.peg.1238', 'fig|470.8208.peg.2478', 'fig|470.8208.peg.2639', 'fig|470.8208.peg.854', 'fig|470.8208.peg.382', 'fig|470.8208.peg.383']
db_xref=[]
for xref in da_xref:
db_xref.append('SEED:' + xref)
with open("nucleotides.fasta", "w") as nt_output, open("proteins.fasta", "w") as aa_output:
for xref in db_xref:
print ("Looking at", xref)
cds_feature = get_cds_feature_with_qualifier_value(genome_record, "db_xref", xref)
gene_sequence = cds_feature.extract(genome_record.seq)
protein_sequence = gene_sequence.translate(table=11, cds=True)
# This is asking Python to halt if the translation does not match:
assert protein_sequence == cds_feature.qualifiers["translation"][0]
# Output FASTA records - note \n means insert a new line.
# This is a little lazy as it won't line wrap the sequence:
nt_output.write(">%s\n%s\n" % (xref, gene_sequence))
aa_output.write(">%s\n%s\n" % (xref, gene_sequence))
print("Done")
'''
I have sought different articles here about searching data from a list, but nothing seems to be working right or is appropriate in what I am supposed to implement.
I have this pre-created module with over 500 list (they are strings, yes, but is considered as list when called into function; see code below) of names, city, email, etc. The following are just a chunk of it.
empRecords="""Jovita,Oles,8 S Haven St,Daytona Beach,Volusia,FL,6/14/1965,32114,386-248-4118,386-208-6976,joles#gmail.com,http://www.paganophilipgesq.com,;
Alesia,Hixenbaugh,9 Front St,Washington,District of Columbia,DC,3/3/2000,20001,202-646-7516,202-276-6826,alesia_hixenbaugh#hixenbaugh.org,http://www.kwikprint.com,;
Lai,Harabedian,1933 Packer Ave #2,Novato,Marin,CA,1/5/2000,94945,415-423-3294,415-926-6089,lai#gmail.com,http://www.buergimaddenscale.com,;
Brittni,Gillaspie,67 Rv Cent,Boise,Ada,ID,11/28/1974,83709,208-709-1235,208-206-9848,bgillaspie#gillaspie.com,http://www.innerlabel.com,;
Raylene,Kampa,2 Sw Nyberg Rd,Elkhart,Elkhart,IN,12/19/2001,46514,574-499-1454,574-330-1884,rkampa#kampa.org,http://www.hermarinc.com,;
Flo,Bookamer,89992 E 15th St,Alliance,Box Butte,NE,12/19/1957,69301,308-726-2182,308-250-6987,flo.bookamer#cox.net,http://www.simontonhoweschneiderpc.com,;
Jani,Biddy,61556 W 20th Ave,Seattle,King,WA,8/7/1966,98104,206-711-6498,206-395-6284,jbiddy#yahoo.com,http://www.warehouseofficepaperprod.com,;
Chauncey,Motley,63 E Aurora Dr,Orlando,Orange,FL,3/1/2000,32804,407-413-4842,407-557-8857,chauncey_motley#aol.com,http://www.affiliatedwithtravelodge.com
"""
a = empRecords.strip().split(";")
And I have the following code for searching:
import empData as x
def seecity():
empCitylist = list()
for ct in x.a:
empCt = ct.strip().split(",")
empCitylist.append(empCt)
t = sorted(empCitylist, key=lambda x: x[3])
for c in t:
city = (c[3])
print(city)
live_city = input("Enter city: ")
for cy in city:
if live_city in cy:
print(c[1])
# print("Name: "+ c[1] + ",", c[0], "| Current City: " + c[3])
Forgive my idiotic approach as I am new to Python. However, what I am trying to do is user will input the city, then the results should display the employee's last name, first name who are living in that city (I dunno if I made sense lol)
By the way, the code I used above doesn't return any answers. It just loops to the input.
Thank you for helping. Lovelots. <3
PS: the format of the empData is: first name, last name, address, city, country, birthday, zip, phone, and email
You can use the csv module to read easily a file with comma separated values
import csv
with open('test.csv', newline='') as csvfile:
records = list(csv.reader(csvfile))
def search(data, elem, index):
out = list()
for row in data:
if row[index] == elem:
out.append(row)
return out
#test
print(search(records, 'Orlando', 3))
Based on your original code, you can do it like this:
# Make list of list records, sorted by city
t = sorted((ct.strip().split(",") for ct in x.a), key=lambda x: x[3])
# List cities
print("Cities in DB:")
for c in t:
city = (c[3])
print("-", city)
# Define search function
def seecity():
live_city = input("Enter city: ")
for c in t:
if live_city == c[3]:
print("Name: "+ c[1] + ",", c[0], "| Current City: " + c[3])
seecity()
Then, after you understand what's going on, do as #Hoxha Alban suggested, and use the csv module.
The beauty of python lies in list comprehension.
empRecords="""Jovita,Oles,8 S Haven St,Daytona Beach,Volusia,FL,6/14/1965,32114,386-248-4118,386-208-6976,joles#gmail.com,http://www.paganophilipgesq.com,;
Alesia,Hixenbaugh,9 Front St,Washington,District of Columbia,DC,3/3/2000,20001,202-646-7516,202-276-6826,alesia_hixenbaugh#hixenbaugh.org,http://www.kwikprint.com,;
Lai,Harabedian,1933 Packer Ave #2,Novato,Marin,CA,1/5/2000,94945,415-423-3294,415-926-6089,lai#gmail.com,http://www.buergimaddenscale.com,;
Brittni,Gillaspie,67 Rv Cent,Boise,Ada,ID,11/28/1974,83709,208-709-1235,208-206-9848,bgillaspie#gillaspie.com,http://www.innerlabel.com,;
Raylene,Kampa,2 Sw Nyberg Rd,Elkhart,Elkhart,IN,12/19/2001,46514,574-499-1454,574-330-1884,rkampa#kampa.org,http://www.hermarinc.com,;
Flo,Bookamer,89992 E 15th St,Alliance,Box Butte,NE,12/19/1957,69301,308-726-2182,308-250-6987,flo.bookamer#cox.net,http://www.simontonhoweschneiderpc.com,;
Jani,Biddy,61556 W 20th Ave,Seattle,King,WA,8/7/1966,98104,206-711-6498,206-395-6284,jbiddy#yahoo.com,http://www.warehouseofficepaperprod.com,;
Chauncey,Motley,63 E Aurora Dr,Orlando,Orange,FL,3/1/2000,32804,407-413-4842,407-557-8857,chauncey_motley#aol.com,http://www.affiliatedwithtravelodge.com
"""
rows = empRecords.strip().split(";")
data = [ r.strip().split(",") for r in rows ]
then you can use any condition to filter the list, like
print ( [ "Name: " + emp[1] + "," + emp[0] + "| Current City: " + emp[3] for emp in data if emp[3] == "Washington" ] )
['Name: Hixenbaugh,Alesia| Current City: Washington']
Im creating a code in which I need to check the list ip addresses from npat variable which i need to create a loop, the code will run two things 1 is grep and 2 is lookup using whois both of this task has 2 possible output and its either match or unmatch and result should be in the list.
Q's:
store the if/else statement result into a list that is the result from grep/whois?
What pattern should I use to match route: (spaces) from whois? so far my regex pattern for this work especially matching the address but I'm having issue matching the word "route:(spaces).
Some output:
npat list = ['6.120.0.0/18', '6.120.0.0/17', '13.44.61.0/24', '13.44.62.0/24']
Whois possible output:
1.
RADB: % No entries found for the selected source(s).
RADB: route: 6.120.0.0/18
descr: name.com
origin: AS1111
notify: network#email.com
source: RADB
Here's the code:
import re, base64, os, sys
#SAMPLE STRING
teststr = """router#sh ip bgp
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, x best-external
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 6.120.0.0/18 2.2.2.11 0 3111 2000 2485 43754 i
*> 6.120.0.0/17 2.2.2.11 0 3111 2000 2485 43754 i
*> 13.44.61.0/24 2.2.2.11 0 3111 4559 i
*> 13.44.62.0/24 2.2.2.11 0 3111 4559 i"""
##print (teststr,"\n")
#SEARCH NETWORK ENTRY*Working)
npat = re.findall(r'(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})/\d+',teststr)
print ("List: \n",npat)
for ips in npat:
ipnet = ips.strip()
print ("Processing ..... ", ipnet)
fgen = "grep " +ipnet+ " /mnt/hgfs/IRR/fgen.txt"
f2pat = re.findall(ipnet,fgen)
print ("\nCommand: ",fgen)
os.system(fgen)
print ("\n NEW NPATH: ",f2pat)
if ipnet in f2pat:
flist = "Grep Found"
print ("Result ", flist)
else:
flist = "Grep Not found"
print ("Result: ",flist)
f = os.popen('whois -h whois.radb.net ' + ipnet)
who = f.read()
radbpat = re.findall(ipnet,who)
print ("\nRADB: ", who)
radbpat = re.findall(r'(?<=route: )(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})/\d+',who)
print ("Radb :",radbpat)
if ipnet in radbpat:
rlist = "Found in RADB"
print ("Result ", rlist)
else:
rlist = "Not found in RADB"
print ("Result: ",rlist)
## OUTPUT
titles = ['RS-SET', 'GREP', 'RADB']
data = [titles] + list(zip(npat, flist, rlist))
for i, d in enumerate(data):
line = '|'.join(str(x).ljust(15) for x in d)
print(line)
if i == 0:
print('-' * len(line))
My target is to create a loop so I could check all the list of ip address from npat then the output shows the result from task 1 and 2??
I have created a table so my target output should be like this.
RS-SET |Grep |RADB
--------------------------------------------
xx.xx.xx.0/yy |not found |Found
My Current output is like this:
RS-SET |GREP |RADB
-----------------------------------------------
27.54.41.0/24 |G |N
223.253.0.0/20 |r |o
27.54.41.0/24 |e |t
27.54.42.0/24 |p |
27.54.43.0/24 | |f
Grep and radb output has been vertically added... my flist and rlist has only 1 data.
I want to control my python script output with values in a csv:
I select a Category and some parameters like that:
csv1
or like that csv2
In my python-script I got the Values of each parameter in a list that looks like that:
A_Names = ("Anton", "Berta", "Charlie")
Ages = ("32","18","23")
Nicknames = ("Agent A", "Agent B", None)
Birthdays = ("03.03.1986", "02.02.2000", "01.01.1995")
IDs = (100, 200, 300)
The idea now is to have a script that will combine these information so the output for csv1 would be:
Anton
A_Name: Anton
Age: 32
Nickname: Agent A
Birthday: 03.03.1986
Berta
A_Name: Berta
Age: 18
Nickname: Agent B
Birthday: 02.02.2000
Charlie
A_Name: Charlie
Age: 23
Nickname: No Nickname yet
Birthday: 01.01.1995
and the output for the csv2 would be:
Anton
Nickname: Agent A
A_Name: Anton
ID: 100
Berta
Nickname: Agent B
A_Name: Berta
ID: 200
Charlie
Nickname: No Nickname yet
A_Name: Charlie
ID: 300
and of course it should also work both together in a csv3 like that, and the same outputs just after another.
So the first idea was just to code my output like that:
#let's assume i got the columns from the csv in lists like that:
Categories = ("Agents", "Agents")
Parameter1 = ("A_Name", "Nickname")
Parameter2 = ("Age", "A_Name")
Parameter3 = ("Nickname", "ID")
Parameter4 = ("Birthday")
#then the most unflexible code would look like that:
def Show_Values():
for n in range (0,len(A_Names)):
print A_Names[n]
print " %s: %s" % (Parameter1[0], A_Names[n])
print " %s: %s" % (Parameter2[0], Ages[n])
print " %s: %s" % (Parameter3[0], Nicknames[n])
print " %s: %s" % (Parameter4[0], Birthdays[n])
for n in range (0,len(A_Names)):
print A_Names[n]
print " %s: %s" % (Parameter1[1], Nicknames[n])
print " %s: %s" % (Parameter2[1], A_Names[n])
print " %s: %s" % (Parameter3[1], IDs[n])
Show_Values()
So this is very stupid code and I repeat myself there over and over and always need to add the correct value for the 2nd %s.
My question now is how can I create a smarter, shorter Code, that knows that A_Name[0] is the first Element of A_Names.
And that he should add the "%s: %s" % (parameter, value), automatically for the amount of parameters I am looking for via the csv. I think I need
the length of the row for that so two more lists from the csv:
Row0 = (Agents, A_Name, Age, Nickname, Birthday)
Row1 = (Agents, Nickname, A_Name, ID)
len(Row0)-1
len(Row1)-1
edit:
Ok thank you so far, here's my new approach, reading rows only from a csv:
import csv
with open("TableAgentsComma.csv", "rb") as file:
reader = csv.reader(file, delimiter=",")
inputHeader = next(reader)
rows=[r for r in reader]
A_Names = ["Anton", "Berta", "Charlie"]
Ages = ["32","18","23"]
Nicknames = ["Agent A", "Agent B", None]
Birthdays = ["03.03.1986", "02.02.2000", "01.01.1995"]
IDs = [100, 200, 300]
def Show_Values():
for n in range (0, len(A_Names)):
print A_Names[n]
print " %s: %s" % (rows[0][1], A_Names[n])
print " %s: %s" % (rows[0][2], Ages[n])
print " %s: %s" % (rows[0][3], Nicknames[n])
print " %s: %s" % (rows[0][4], Birthdays[n])
for n in range (0, len(A_Names)):
print A_Names[n]
print " %s: %s" % (rows[1][1], Nicknames[n])
print " %s: %s" % (rows[1][2], A_Names[n])
print " %s: %s" % (rows[1][3], IDs[n])
Show_Values()
But of course it's still an inflexible script and I would like it to respond to the csv, and generate its output depending on the amount of rows and the parameters inside.
Also I need to find out how the script will know that the parameter "ID" is found in the list IDs etc.
The csv file:
Category,Parameter1,Parameter2,Parameter3,Parameter4,Parameter5,
Agents,A_Name,Age,Nickname,Birthday,,
Agents,Nickname,A_Name,ID,,,
Agents,A_Name,Age,,,,
Agents,ID,,,,,
If you store the data as a dictionary you can look up the key based on the name in the csv file:
data = {
"A_Names" : ["Anton", "Berta", "Charlie"],
"Ages" : ["32","18","23"],
"Nicknames": ["Agent A", "Agent B", None],
"Birthdays": ["03.03.1986", "02.02.2000", "01.01.1995"],
"IDs": [100, 200, 300]
}
def Show_Values():
for row in rows:
for n in range (0, len(data["A_Names"])):
print data["A_Names"][n]
for header in row:
if header == "Agents" or header == "": # This field doesn't match any thing in the data.
continue
header = header.strip()
header += "s"
print " %s: %s" % (header, data[header][n])
Since the data is now in a dict we can look up the value based on the parameter which we got from the file. I probably should have called it "parameter" rather than "header".
Show_Values()
Output:
Anton
A_Names: Anton
Ages: 32
Nicknames: Agent A
Birthdays: 03.03.1986
Berta
A_Names: Berta
Ages: 18
Nicknames: Agent B
Birthdays: 02.02.2000
Charlie
A_Names: Charlie
Ages: 23
Nicknames: None
Birthdays: 01.01.1995
And then from the second row in the .csv:
Anton
Nicknames: Agent A
A_Names: Anton
IDs: 100
Berta
Nicknames: Agent B
A_Names: Berta
IDs: 200
Charlie
Nicknames: None
A_Names: Charlie
IDs: 300
I have written a wlst script to create multiple connection factories. Code is as below :
def createJMSConnFac(systemModuleName,ConnectionFactoryJNDIName,connectionFactoryName):
cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName)
cmo.createConnectionFactory(connectionFactoryName)
cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName+'/ConnectionFactories/'+connectionFactoryName)
cmo.setJNDIName(ConnectionFactoryJNDIName)
print "Created a ConnectionFactory !!"
cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName+'/ConnectionFactories/'+connectionFactoryName+'/SecurityParams/'+connectionFactoryName)
cmo.setAttachJMSXUserId(false)
cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName+'/ConnectionFactories/'+connectionFactoryName)
cmo.setDefaultTargetingEnabled(true)
print "Targeted the ConnectionFactory !!"
And the loop from which this method gets called is :
y=1
while(y <= int(total_conf)):
print '----------- Connection Factory Creation ---------'
print 'Total Conf :' +total_conf
conf_name=configProps.get("conf_name"+ str(a) + "." +str(y))
conf_jndi=configProps.get("conf_jndi"+ str(a) + "." +str(y))
print 'Conf Name :' +conf_name
print 'Conf JNDI :' +conf_jndi
print 'Conf JMS Mod Name :'+jms_mod_name
print a
print y
createJMSConnFac(jms_mod_name,conf_jndi,conf_name)
y = y + 1
Interesting thing to note here is that : It creates connfac1 properly however as soon as it iterates for second time , it throws me an error saying :
WLSTException: Error cding to the MBean on line 4
The values of jms_mod_name , conf_jndi and conf_name are being printed properly in both the iterations.
Is there anything else that I may be missing here ? Request your help
Thanks ,
Bhavin
I was able to create 3(or more) CFs with this code :
def createJMSConnFac(systemModuleName,ConnectionFactoryJNDIName,connectionFactoryName):
cmo=cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName)
cmo.createConnectionFactory(connectionFactoryName)
cmo=cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName+'/ConnectionFactories/'+connectionFactoryName)
cmo.setJNDIName(ConnectionFactoryJNDIName)
print "Created a ConnectionFactory !!"
cmo=cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName+'/ConnectionFactories/'+connectionFactoryName+'/SecurityParams/'+connectionFactoryName)
cmo.setAttachJMSXUserId(false)
cmo=cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName+'/ConnectionFactories/'+connectionFactoryName)
cmo.setDefaultTargetingEnabled(true)
print "Targeted the ConnectionFactory !!"
connect("weblogic","password","t3://host:port")
edit()
startEdit()
y=1
while(y <= 3):
print '----------- Connection Factory Creation ---------'
conf_name="conf_name." +str(y)
conf_jndi="conf_jndi." +str(y)
print 'Conf Name :' +conf_name
print 'Conf JNDI :' +conf_jndi
#print a
print y
createJMSConnFac('testModule',conf_jndi,conf_name)
y = y + 1
save()
activate(block="true")
disconnect()