Skip to content
This repository has been archived by the owner on Jan 29, 2019. It is now read-only.

Convert to Python3 #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion DARE-BIGJOB/apps/darewap/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def get_pilot_info(self):
'number_of_processes': self.number_of_processes,
'cores_per_node': self.cores_per_node
}
for key in pilotdescdict.keys():
for key in list(pilotdescdict.keys()):
pilotdescdict[key] = str(pilotdescdict[key])
return pilotdescdict

Expand Down
26 changes: 13 additions & 13 deletions DARE-BIGJOB/apps/darewap/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
def start_run_pilot(pilot_id, coordination_url=COORD_URL):
pilot = DareBigJobPilot.objects.get(id=pilot_id)
pilot_compute_service = PilotComputeService(coordination_url=COORD_URL)
print pilot.get_pilot_info()
print(pilot.get_pilot_info())
pilot_compute = pilot_compute_service.create_pilot(pilot_compute_description=pilot.get_pilot_info())
pilot.pilot_url = pilot_compute.get_url()
pilot.status = "Submitted"
pilot.save()
print("Started Pilot: %s " % (pilot.pilot_url), pilot.id)
print(("Started Pilot: %s " % (pilot.pilot_url), pilot.id))


@task
Expand All @@ -49,7 +49,7 @@ def update_status_run_pilot(pilot_id):
pilot.status = "New"

pilot.save()
print("Stopped Pilot: %s " % (pilot_url), pilot.id)
print(("Stopped Pilot: %s " % (pilot_url), pilot.id))


@task
Expand All @@ -63,7 +63,7 @@ def stop_run_pilot(pilot_id):
pilot.status = "Stopped"
pilot.save()

print("Stopped Pilot: %s " % (pilot_url), pilot.id)
print(("Stopped Pilot: %s " % (pilot_url), pilot.id))


@task
Expand All @@ -84,7 +84,7 @@ def start_run_task(task_id):
taskinfo.cu_url = ''
for cu in cus:
compute_unit = pilot_compute.submit_compute_unit(cu)
print "Started ComputeUnit: %s" % (compute_unit.get_url())
print("Started ComputeUnit: %s" % (compute_unit.get_url()))
taskinfo.cu_url += '@@@' + compute_unit.get_url()
taskinfo.status = 'Submitted'
taskinfo.save()
Expand All @@ -100,12 +100,12 @@ def stop_run_task(task_id):
if len(cu_url) > 0:
compute_unit = ComputeUnit(cu_url=str(cu_url))
compute_unit.cancel()
print(compute_unit.get_state())
print((compute_unit.get_state()))
taskinfo.cu_url = ""
taskinfo.status = "Stopped"
taskinfo.save()

print("Stopped Task: ", taskinfo.id)
print(("Stopped Task: ", taskinfo.id))


@task
Expand All @@ -128,7 +128,7 @@ def update_status_run_task(task_id):

taskinfo.status = all_status
taskinfo.save()
print("Updated Status Task: ", task_id)
print(("Updated Status Task: ", task_id))

CONDOR_URL = "condor://localhost?WhenToTransferOutput=ON_EXIT&should_transfer_files=YES&notification=Always"

Expand Down Expand Up @@ -168,14 +168,14 @@ def start_run_osg_task(task_id):
sleepjob = js.create_job(jd)

# check our job's id and state
print "Job ID : %s" % (sleepjob.id)
print "Job State : %s" % (sleepjob.state)
print("Job ID : %s" % (sleepjob.id))
print("Job State : %s" % (sleepjob.state))

print "\n...starting job...\n"
print("\n...starting job...\n")
sleepjob.run()

print "Job ID : %s" % (sleepjob.id)
print "Job State : %s" % (sleepjob.state)
print("Job ID : %s" % (sleepjob.id))
print("Job State : %s" % (sleepjob.state))


def get_osg_task_status(task_id):
Expand Down
14 changes: 7 additions & 7 deletions DARE-BIGJOB/apps/darewap/templatetags/daretags.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,34 @@ def timesince_human(date): # TODO: let user specify format strings

num_years = delta.days / 365
if (num_years > 0):
return ungettext(u"%d year ago", u"%d years ago", num_years) % (
return ungettext("%d year ago", "%d years ago", num_years) % (
num_years,)

num_months = delta.days / 30
if (num_months > 0):
return ungettext(u"%d month ago", u"%d months ago",
return ungettext("%d month ago", "%d months ago",
num_months) % num_months

num_weeks = delta.days / 7
if (num_weeks > 0): # TODO: "last week" if num_weeks == 1
return ungettext(u"%d week ago", u"%d weeks ago",
return ungettext("%d week ago", "%d weeks ago",
num_weeks) % num_weeks

if (delta.days > 0): # TODO: "yesterday" if days == 1
return ungettext(u"%d day ago", u"%d days ago",
return ungettext("%d day ago", "%d days ago",
delta.days) % delta.days

num_hours = delta.seconds / 3600
if (num_hours > 0): # TODO: "an hour ago" if num_hours == 1
return ungettext(u"%d hour ago", u"%d hours ago",
return ungettext("%d hour ago", "%d hours ago",
num_hours) % num_hours

num_minutes = delta.seconds / 60
if (num_minutes > 0): # TODO: "a minute ago" if num_minutes == 1
return ungettext(u"%d minute ago", u"%d minutes ago",
return ungettext("%d minute ago", "%d minutes ago",
num_minutes) % num_minutes

return ugettext(u"just now")
return ugettext("just now")



Expand Down
2 changes: 1 addition & 1 deletion DARE-BIGJOB/apps/invitation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class InvitationKey(models.Model):
objects = InvitationKeyManager()

def __unicode__(self):
return u"Invitation from %s on %s" % (self.from_user.username, self.date_invited)
return "Invitation from %s on %s" % (self.from_user.username, self.date_invited)

def is_usable(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion DARE-BIGJOB/apps/invitation/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


def check_valid_key(request, *args, **kwargs):
print kwargs.get('username')
print(kwargs.get('username'))
if not user_exists(username=kwargs.get('username')):
if request.session.get('invitation_key') and is_key_valid(request.session['invitation_key']):
return {}
Expand Down
2 changes: 1 addition & 1 deletion DARE-BIGJOB/apps/invitation/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def test_invitation_form(self):
# Invalid email.
{
'data': { 'email': 'example.com' },
'error': ('email', [u"Enter a valid e-mail address."])
'error': ('email', ["Enter a valid e-mail address."])
},
]

Expand Down
2 changes: 1 addition & 1 deletion DARE-BIGJOB/dare-site/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
else:
from env_settings.local.settings import *
except:
print 'error'
print('error')
4 changes: 2 additions & 2 deletions old/framework/dare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__version__ = '.'.join(__version_info__)

import os
import ConfigParser
import configparser

from .helpers.misc import darelogger

Expand All @@ -23,7 +23,7 @@

darelogger.info("Loading settings in %s" % _conf_file)

cfgparser = ConfigParser.ConfigParser()
cfgparser = configparser.ConfigParser()
cfgparser.read(_conf_file)
cfgdict = cfgparser.defaults()
COORDINATION_URL = str(cfgdict.get('coordination_url'))
Expand Down
10 changes: 5 additions & 5 deletions old/framework/dare/core/dare_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ def start(self):
self.pilot_compute_service = PilotComputeService(coordination_url=COORDINATION_URL)
self.pilot_data_service = PilotDataService(coordination_url=COORDINATION_URL)

for compute_pilot, desc in self.workflow.compute_pilot_repo.items():
for compute_pilot, desc in list(self.workflow.compute_pilot_repo.items()):
self.pilot_compute_service.create_pilot(pilot_compute_description=desc)

for data_pilot, desc in self.workflow.data_pilot_repo.items():
for data_pilot, desc in list(self.workflow.data_pilot_repo.items()):
self.data_pilot_service_repo.append(self.pilot_data_service.create_pilot(pilot_data_description=desc))

self.compute_data_service = ComputeDataServiceDecentral()
Expand All @@ -56,7 +56,7 @@ def start(self):
self.step_start_lock = threading.RLock()
self.step_run_lock = threading.RLock()

for step_id in self.workflow.step_units_repo.keys():
for step_id in list(self.workflow.step_units_repo.keys()):
darelogger.info(" Sumitted step %s " % step_id)
self.step_start_lock.acquire()
self.start_thread_step_id = step_id
Expand All @@ -65,7 +65,7 @@ def start(self):
self.step_threads[step_id].start()

while(1):
count_step = [v.is_alive() for k, v in self.step_threads.items()]
count_step = [v.is_alive() for k, v in list(self.step_threads.items())]
darelogger.info('count_step %s' % count_step)
if not True in count_step and len(count_step) > 0:
break
Expand Down Expand Up @@ -179,7 +179,7 @@ def quit(self, message=None):
if message:
darelogger.debug(message)
darelogger.debug("Terminating steps")
for step, thread in self.step_threads.items():
for step, thread in list(self.step_threads.items()):
darelogger.debug("Stoppping step %s" % step)
thread._Thread__stop()

Expand Down
8 changes: 4 additions & 4 deletions old/framework/dare/helpers/cfgparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__license__ = "MIT"


import ConfigParser
import configparser
import os
import sys
from dare import darelogger
Expand All @@ -18,7 +18,7 @@ def __init__(self, conf_file="/default/conf/file/"):
raise RuntimeError("Cannot find %s " % self.conf_file)

#parse job conf file
self.config = ConfigParser.ConfigParser()
self.config = configparser.ConfigParser()
self.config.read(self.conf_file)

def SectionDict(self, section):
Expand All @@ -31,14 +31,14 @@ def SectionDict(self, section):

class CfgWriter(object):
def __init__(self, conffile):
self.dare_config = ConfigParser.ConfigParser()
self.dare_config = configparser.ConfigParser()
self.conffile = conffile

def add_section(self, section_params):
section_name = section_params.pop("name")
self.dare_config.add_section(section_name)

for k, v in section_params.items():
for k, v in list(section_params.items()):
self.dare_config.set(section_name, k, v)

def write(self):
Expand Down
6 changes: 3 additions & 3 deletions old/framework/dare/helpers/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

class DareLogger():
def debug(self, p):
print "DARE-Debug-%s" % p
print("DARE-Debug-%s" % p)

def info(self, p):
print "DARE-info-%s" % p
print("DARE-info-%s" % p)

def error(self, p):
print "DARE-error-%s" % p
print("DARE-error-%s" % p)

darelogger = DareLogger()
2 changes: 1 addition & 1 deletion old/framework/dare/helpers/stepunit.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def define_param(self, step_info):
"transfer_output_data_units": step_info.get("transfer_output_data_units"),
"start_after_steps": step_info.get("start_after_steps")
}
print self.UnitInfo
print(self.UnitInfo)

def get_step_id(self):
return self.UnitInfo['step_id']
Expand Down
2 changes: 1 addition & 1 deletion old/framework/distribute_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
from urllib.request import urlopen
tgz_name = "distribute-%s.tar.gz" % version
url = download_base + tgz_name
saveto = os.path.join(to_dir, tgz_name)
Expand Down
2 changes: 1 addition & 1 deletion old/gateways/DARE-CACTUS/apps/cactus/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, user, *args, **kwargs):
def save(self, request):
job = Job(user=request.user, status="New", name=self.cleaned_data['name'])
job.save()
for key, value in self.cleaned_data.items():
for key, value in list(self.cleaned_data.items()):
if key in ['name']:
continue
if key.lower() == 'parameterfile':
Expand Down
2 changes: 1 addition & 1 deletion old/gateways/DARE-CACTUS/apps/invitation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class InvitationKey(models.Model):
objects = InvitationKeyManager()

def __unicode__(self):
return u"Invitation from %s on %s" % (self.from_user.username, self.date_invited)
return "Invitation from %s on %s" % (self.from_user.username, self.date_invited)

def is_usable(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion old/gateways/DARE-CACTUS/apps/invitation/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


def check_valid_key(request, *args, **kwargs):
print kwargs.get('username')
print(kwargs.get('username'))
if not user_exists(username=kwargs.get('username')):
if request.session.get('invitation_key') and is_key_valid(request.session['invitation_key']):
return {}
Expand Down
2 changes: 1 addition & 1 deletion old/gateways/DARE-CACTUS/apps/invitation/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def test_invitation_form(self):
# Invalid email.
{
'data': { 'email': 'example.com' },
'error': ('email', [u"Enter a valid e-mail address."])
'error': ('email', ["Enter a valid e-mail address."])
},
]

Expand Down
2 changes: 1 addition & 1 deletion old/gateways/DARE-CACTUS/dare-site/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from default_settings import *
from .default_settings import *
import os

if os.environ.get('DEVELOPMENT'):
Expand Down
10 changes: 5 additions & 5 deletions old/gateways/DARE-HTHP/darehthp/controllers/hthpmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
import getopt
import logging
import commands
import subprocess
from subprocess import Popen, call, PIPE

from pylons import request, response, session, tmpl_context as c, url
Expand Down Expand Up @@ -111,13 +111,13 @@ def job_status_update(self):

#check job is already done important

print job_pid, "job_pid"
print(job_pid, "job_pid")
if job_pid is None:
redirect(url('/hthpmd/job_table_view'))

if not (os.path.exists("/proc/"+str(job_pid))):
update_job_status(jobid, "3")
print "\n update status failed\n"
print("\n update status failed\n")

redirect(url('/hthpmd/job_table_view'))

Expand All @@ -136,7 +136,7 @@ def namd_form(self):
action = request.params['action']
num = request.POST["numresources"]
numf = request.POST["numfiles"]
print "numf", numf
print("numf", numf)
c.form = NAMDForm(request.POST or None, numresources=num,numfiles=numf)
except:
c.form = NAMDForm(request.POST or None)
Expand Down Expand Up @@ -263,7 +263,7 @@ def job_insert(self):
if not (inftype == 'resource_type'):
add_another = request.POST['add_another']

print "\n\n\n inftype, add_another", inftype, add_another
print("\n\n\n inftype, add_another", inftype, add_another)
else:
resource_type = request.POST['resource_type']

Expand Down
Loading