Skip to content

Commit

Permalink
Merge pull request #2364 from btovar/to_7.1.7
Browse files Browse the repository at this point in the history
To 7.1.7
  • Loading branch information
btovar authored Aug 20, 2020
2 parents f28851a + d710622 commit 5d2c3f8
Show file tree
Hide file tree
Showing 28 changed files with 361 additions and 197 deletions.
57 changes: 27 additions & 30 deletions apps/aws/cctools-AMI.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
import boto.ec2
import sys
import os
import urllib2
import urllib.request, urllib.error, urllib.parse
import datetime
import time

# Simple usage and file existence checks
if len(sys.argv) != 5:
print "usage: "+sys.argv[0]+" <cctools-version-number|cctools-tar.gz> <AWS_Keyfile> <userdata_file> (public|private)"
print("usage: "+sys.argv[0]+" <cctools-version-number|cctools-tar.gz> <AWS_Keyfile> <userdata_file> (public|private)")
sys.exit()

### Check if it's a valid version of cctools ###################
Expand All @@ -38,12 +38,12 @@
tarballTransferred = False
is_tarball = False
try:
returned = urllib2.urlopen(urllib2.Request("http://ccl.cse.nd.edu/software/files/cctools-"+sys.argv[1]+"-"+source_string+".tar.gz"))
returned = urllib.request.urlopen(urllib.request.Request("http://ccl.cse.nd.edu/software/files/cctools-"+sys.argv[1]+"-"+source_string+".tar.gz"))
version_is_good = True
except:
source_string="src"
try:
returned = urllib2.urlopen(urllib2.Request("http://ccl.cse.nd.edu/software/files/cctools-"+sys.argv[1]+"-"+source_string+".tar.gz"))
returned = urllib.request.urlopen(urllib.request.Request("http://ccl.cse.nd.edu/software/files/cctools-"+sys.argv[1]+"-"+source_string+".tar.gz"))
version_is_good = True
except:
version_is_good = False
Expand All @@ -53,15 +53,15 @@
is_tarball = True

if not is_tarball:
print sys.argv[1] + " is not a valid version of cctools and is not an accessible file that can contain cctools"
print(sys.argv[1] + " is not a valid version of cctools and is not an accessible file that can contain cctools")
sys.exit()

if sys.argv[4] == "public":
publicize = True
elif sys.argv[4] == "private":
publicize = False
else:
print "fourth argmuent must be either 'public' or 'private'"
print("fourth argmuent must be either 'public' or 'private'")
sys.exit()

### Valid version check complete ###############################
Expand Down Expand Up @@ -89,13 +89,13 @@ def publicize_amis(connection_amiID_pairs):
for (connection, ami_id) in connection_amiID_pairs:
try:
connection.modify_image_attribute(ami_id, attribute="launchPermission", operation="add", groups=["all"])
print "Image "+ ami_id +" should be publicly available in "+connection.region.name
print("Image "+ ami_id +" should be publicly available in "+connection.region.name)
connection_amiID_pairs.remove((connection, ami_id))
except:
print "Image not ready for publicity in " + connection.region.name
print("Image not ready for publicity in " + connection.region.name)
time.sleep(WAIT_LENGTH)

print "Image should be publicly available in all regions we copied it to."
print("Image should be publicly available in all regions we copied it to.")


def move_tarball(key_pair, dns):
Expand All @@ -106,10 +106,10 @@ def move_tarball(key_pair, dns):
os.system("scp -i ./"+key_pair+".pem -oStrictHostKeyChecking=no ubuntu@"+dns+":/home/ubuntu/GOT_IT .")
if os.path.isfile("./GOT_IT"):
os.system("rm ./GOT_IT")
print "Tarball successfully scp'd"
print("Tarball successfully scp'd")
transfer_done = True
else:
print "Still transferring tarball"
print("Still transferring tarball")
time.sleep(WAIT_LENGTH)

### END DEFINE FUNCTION(S) #######################################
Expand All @@ -128,7 +128,7 @@ def move_tarball(key_pair, dns):

reg_connect = boto.ec2.connect_to_region(region_info.name, aws_access_key_id = access_key_id, aws_secret_access_key = secret_key)
if not reg_connect:
print "connection failed"
print("connection failed")
sys.exit()
###Connection made################################################

Expand All @@ -153,9 +153,7 @@ def move_tarball(key_pair, dns):
try:
user_data = open(user_data_filename).read()
except:
print
print user_data_filename + " could not be opened for reading, so the EC2 instance will not be able to run the installation commands."
print
print("\nfile {} could not be opened for reading, so the EC2 instance will not be able to run the installation commands.\n".format(user_data_filename))
sys.exit()

user_data = user_data.replace("VERSION_NUMBER", sys.argv[1])
Expand All @@ -181,9 +179,8 @@ def move_tarball(key_pair, dns):
#also, we are the only instance using this key pair, so len(instances)==1 should be true
dns_name = new_instance.public_dns_name

print "dns of just started instance is: "+dns_name
print("dns of just started instance is: " + dns_name)
if len(dns_name) > 0:

if(is_tarball and not tarballTransferred):
move_tarball(key_pair_name, dns_name)
tarballTransferred = True
Expand All @@ -192,10 +189,10 @@ def move_tarball(key_pair, dns):
if os.path.isfile("./IM_DONE"):
os.system("rm ./IM_DONE")
os.system("rm ./"+key_pair_name+".pem")
print "Initialization script is finished, waiting for flag to be deleted before snapshotting."
print("Initialization script is finished, waiting for flag to be deleted before snapshotting.")
waiting_on_ec2instance = False
else:
print "Initialization script on new instance is still running"
print("Initialization script on new instance is still running")
###EC2 Instance Created and user_data script finished##############

###Set up for and take the machine image##########################
Expand All @@ -205,11 +202,11 @@ def move_tarball(key_pair, dns):
#the image could be taken when the script is running
for i in range(3):
time.sleep(WAIT_LENGTH)
print "Still waiting..."
print("Still waiting...")

time.sleep(1)

print "Attempting to take image"
print("Attempting to take image")

if(is_tarball):
AMI_name_string = sys.argv[1]+" Starter AMI "+timestamp
Expand All @@ -225,18 +222,18 @@ def move_tarball(key_pair, dns):
if publicize:
publicize_amis([(reg_connect, new_ami_id)])
else:
print "not publicizing"
print("not publicizing")
###ami is now public in the region we created the instance in#######################################

###Terminate the actual instance, we have the AMI#################
print "Image taken. Trying to terminate instance"
print("Image taken. Trying to terminate instance")
terminated_instances = []
terminated_instances = reg_connect.terminate_instances([new_instance.id])
while(len(terminated_instances) <= 0):
time.sleep(WAIT_LENGTH)
terminated_instances = reg_connect.terminate_instances([new_instance.id])

print "Instance terminated."
print("Instance terminated.")
###Instance terminated ###########################################

###we need to copy this public ami to all other regions except the one we created it in#############
Expand All @@ -250,9 +247,9 @@ def move_tarball(key_pair, dns):
for region in regions_to_distribute_to:
new_connection = boto.ec2.connect_to_region(region.name, aws_access_key_id = access_key_id, aws_secret_access_key = secret_key)
if not new_connection:
print "UH OH! No new connection"
print("UH OH! No new connection")
else:
print "Connected to "+ region.name+"for image copying"
print("Connected to " + region.name + " for image copying")
connections_list.append(new_connection)
copy_list.append(new_connection)
copy_dict[new_connection.region.name] = 0
Expand All @@ -262,21 +259,21 @@ def move_tarball(key_pair, dns):
for connection in copy_list:
try:
new_copied_ami_info = connection.copy_image(region_info.name, new_ami_id)
print "new_copied_ami_id = " + str(new_copied_ami_info.image_id) + " for region " + str(connection.region.name)
print("new_copied_ami_id = " + str(new_copied_ami_info.image_id) + " for region " + str(connection.region.name))
to_make_public.append((connection, new_copied_ami_info.image_id))
copy_list.remove(connection)
except:
attempts=copy_dict[connection.region.name]
copy_dict[connection.region.name] = attempts + 1
print "Failed to copy image to " + str(connection.region.name) + " on attempt " + str(attempts) +", connections left: " + str(copy_list)
print("Failed to copy image to " + str(connection.region.name) + " on attempt " + str(attempts) +", connections left: " + str(copy_list))
if attempts >= max_image_copy_attempts:
print "Region " + str(connection.region.name) + " is being uncooperative/does not want our public ami, so it won't get it"
print("Region " + str(connection.region.name) + " is being uncooperative/does not want our public ami, so it won't get it")
copy_list.remove(connection)
time.sleep(WAIT_LENGTH)

if publicize:
publicize_amis(to_make_public)
else:
print "not publicizing"
print("not publicizing")


4 changes: 2 additions & 2 deletions apps/makeflow_blasr/makeflow_blasr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# Copyright (C) 2014- The University of Notre Dame
# This software is distributed under the GNU General Public License.
Expand All @@ -19,7 +19,7 @@ class PassThroughParser(optparse.OptionParser):
while rargs:
try:
optparse.OptionParser._process_args(self,largs,rargs,values)
except (optparse.BadOptionError,optparse.AmbiguousOptionError), e:
except (optparse.BadOptionError,optparse.AmbiguousOptionError) as e:
largs.append(e.opt_str)

def parse_blasr_options(parser):
Expand Down
8 changes: 4 additions & 4 deletions apps/makeflow_blast/makeflow_blast
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# Copyright (C) 2011- The University of Notre Dame
# This software is distributed under the GNU General Public License.
Expand All @@ -15,7 +15,7 @@ class PassThroughParser(optparse.OptionParser):
while rargs:
try:
optparse.OptionParser._process_args(self,largs,rargs,values)
except (optparse.BadOptionError,optparse.AmbiguousOptionError), e:
except (optparse.BadOptionError,optparse.AmbiguousOptionError) as e:
largs.append(e.opt_str)

#Parser initialization
Expand Down Expand Up @@ -67,7 +67,7 @@ def write_split_fasta(destination):
split_fasta = open(destination, "w")
try:
log.info("\tWriting Partitioning Script to : {0}".format(destination))
split_fasta.write('''#! /usr/bin/env python
split_fasta.write('''#! /usr/bin/env python3
# Copyright (C) 2011- The University of Notre Dame
# This software is distributed under the GNU General Public License.
Expand Down Expand Up @@ -285,7 +285,7 @@ else:
dbpath = os.path.dirname(db)
for fn in os.listdir(dbpath):
oloc = "{0}/{1}\n".format(dbpath, fn)
print "{0}\n".format(oloc)
print("{0}\n".format(oloc))
if options.database in fn:
os.symlink(oloc, "{0}/{1}".format(options.database, fn))
log.info("Databse linked from : {0}/{1}".format(dbpath, options.database))
Expand Down
4 changes: 2 additions & 2 deletions apps/makeflow_bwa/makeflow_bwa
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
#Copyright (C) 2013- The University of Notre Dame
#This software is distributed under the GNU General Public License.
Expand Down Expand Up @@ -33,7 +33,7 @@ class PassThroughParser(optparse.OptionParser):
while rargs:
try:
optparse.OptionParser._process_args(self,largs,rargs,values)
except (optparse.AmbiguousOptionError, optparse.BadOptionError), e:
except (optparse.AmbiguousOptionError, optparse.BadOptionError) as e:
bwa_args[current_algo].append(e.opt_str)
if "--" not in rargs[0]:
bwa_args[current_algo].append(rargs[0])
Expand Down
4 changes: 2 additions & 2 deletions apps/makeflow_gatk/makeflow_gatk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
#Copyright (C) 2013- The University of Notre Dame
#This software is distributed under the GNU General Public License.
Expand All @@ -18,7 +18,7 @@ class PassThroughParser(optparse.OptionParser):
while rargs:
try:
optparse.OptionParser._process_args(self,largs,rargs,values)
except (optparse.BadOptionError,optparse.AmbiguousOptionError), e:
except (optparse.BadOptionError,optparse.AmbiguousOptionError) as e:
largs.append(e.opt_str)

def parse_req(parser):
Expand Down
2 changes: 1 addition & 1 deletion apps/wq_replica_exchange/protomol_functions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import random
import math

Expand Down
2 changes: 1 addition & 1 deletion apps/wq_replica_exchange/wq_replica_exchange
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# replica_exchange.py
#
Expand Down
Loading

0 comments on commit 5d2c3f8

Please sign in to comment.