-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DM7183: Port to Python 3 #2
Changes from 10 commits
1b7ba48
60c30eb
ef9954f
b242bf6
4330266
80dd10b
8a9e90b
5d3e4a3
00a7e68
962de0b
7e3e33d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ config.log | |
*.pyc | ||
*_wrap.cc | ||
*Lib.py | ||
_build.* | ||
doc/xml | ||
doc/html | ||
doc/*.tag | ||
doc/*.inc | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,76 @@ | ||
#!/usr/bin/env python | ||
|
||
# | ||
# | ||
# LSST Data Management System | ||
# Copyright 2008, 2009, 2010 LSST Corporation. | ||
# | ||
# | ||
# This product includes software developed by the | ||
# LSST Project (http://www.lsst.org/). | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the LSST License Statement and | ||
# the GNU General Public License along with this program. If not, | ||
# | ||
# You should have received a copy of the LSST License Statement and | ||
# the GNU General Public License along with this program. If not, | ||
# see <http://www.lsstcorp.org/LegalNotices/>. | ||
# | ||
|
||
import os, os.path, sys, time | ||
from __future__ import print_function | ||
import os | ||
import os.path | ||
import sys | ||
import time | ||
import optparse | ||
|
||
# filewaiter.py - wait for creation of files | ||
if __name__ == "__main__": | ||
|
||
|
||
usage = """usage: %prog [-f|-l] filenames.txt""" | ||
|
||
parser = optparse.OptionParser(usage) | ||
# TODO: handle "--dryrun" | ||
parser.add_option("-f", "--first", action="store_const", const=1, dest="bFirst", help="wait for first file in list") | ||
parser.add_option("-l", "--list", action="store_const", const=1, dest="bList", help="wait for all the files in the list") | ||
parser.add_option("-f", "--first", action="store_const", const=1, | ||
dest="bFirst", help="wait for first file in list") | ||
parser.add_option("-l", "--list", action="store_const", const=1, | ||
dest="bList", help="wait for all the files in the list") | ||
|
||
parser.opts = {} | ||
parser.args = [] | ||
|
||
# parse and check command line arguments | ||
(parser.opts, parser.args) = parser.parse_args() | ||
if len(parser.args) < 1: | ||
print usage | ||
print(usage) | ||
raise RuntimeError("Missing args: pipelinePolicyFile runId") | ||
|
||
filename = parser.args[0] | ||
|
||
bFirst = parser.opts.bFirst | ||
bFirst = parser.opts.bFirst | ||
bList = parser.opts.bList | ||
|
||
f = open(filename, 'r') | ||
|
||
lines = f.readlines() | ||
|
||
list = [] | ||
fileList = [] | ||
for line in lines: | ||
list.append(line.split('\n')[0]) | ||
|
||
|
||
if bFirst == True: | ||
item = list[0] | ||
while os.path.exists(item) == False: | ||
if bFirst: | ||
item = fileList[0] | ||
while not os.path.exists(item): | ||
time.sleep(1) | ||
sys.exit(0) | ||
|
||
while len(list) > 0: | ||
newlist = [ item for item in list if (os.path.exists(item) == False)] | ||
list = newlist | ||
while len(fileList) > 0: | ||
newlist = [item for item2 in fileList if (os.path.exists(item) is False)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand why this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Excellent catch. It would seem this should be newlist = [item for item in fileList if not os.path.exists(item)] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in DM-7639; rewrote this loop. |
||
fileList = newlist | ||
time.sleep(1) | ||
sys.exit(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-wrote this loop in DM-7639