git://git.onelab.eu
/
sfa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
93a1047
)
open() instead of file()
author
Thierry Parmentelat
<thierry.parmentelat@inria.fr>
Fri, 1 Apr 2016 09:22:25 +0000
(11:22 +0200)
committer
Thierry Parmentelat
<thierry.parmentelat@inria.fr>
Fri, 1 Apr 2016 10:02:14 +0000
(12:02 +0200)
clientbin/sfiAddLinks.py
patch
|
blob
|
history
clientbin/sfiAddSliver.py
patch
|
blob
|
history
flashpolicy/sfa_flashpolicy.py
patch
|
blob
|
history
sfa/client/manifolduploader.py
patch
|
blob
|
history
sfa/client/sfaclientlib.py
patch
|
blob
|
history
sfa/client/sfascan.py
patch
|
blob
|
history
sfa/client/sfi.py
patch
|
blob
|
history
sfa/trust/credential.py
patch
|
blob
|
history
diff --git
a/clientbin/sfiAddLinks.py
b/clientbin/sfiAddLinks.py
index
2e667b1
..
b16cae6
100755
(executable)
--- a/
clientbin/sfiAddLinks.py
+++ b/
clientbin/sfiAddLinks.py
@@
-21,15
+21,15
@@
if not command.opts.linkfile:
sys.exit(1)
if command.opts.infile:
sys.exit(1)
if command.opts.infile:
- infile
=file
(command.opts.infile)
+ infile
= open
(command.opts.infile)
else:
else:
- infile
=
sys.stdin
+ infile
=
sys.stdin
if command.opts.outfile:
if command.opts.outfile:
- outfile
=file(command.opts.outfile,
"w")
+ outfile
= open(command.opts.outfile,
"w")
else:
else:
- outfile
=
sys.stdout
+ outfile
=
sys.stdout
ad_rspec = RSpec(infile)
ad_rspec = RSpec(infile)
-links =
file
(command.opts.linkfile).read().split('\n')
+links =
open
(command.opts.linkfile).read().split('\n')
link_tuples = map(lambda x: tuple(x.split()), links)
version_manager = VersionManager()
link_tuples = map(lambda x: tuple(x.split()), links)
version_manager = VersionManager()
diff --git
a/clientbin/sfiAddSliver.py
b/clientbin/sfiAddSliver.py
index
84ffa8b
..
6e6042c
100755
(executable)
--- a/
clientbin/sfiAddSliver.py
+++ b/
clientbin/sfiAddSliver.py
@@
-21,15
+21,15
@@
if not command.opts.nodefile:
sys.exit(1)
if command.opts.infile:
sys.exit(1)
if command.opts.infile:
- infile
=file
(command.opts.infile)
+ infile
= open
(command.opts.infile)
else:
else:
- infile
=
sys.stdin
+ infile
=
sys.stdin
if command.opts.outfile:
if command.opts.outfile:
- outfile
=file
(command.opts.outfile,"w")
+ outfile
= open
(command.opts.outfile,"w")
else:
else:
- outfile
=
sys.stdout
+ outfile
=
sys.stdout
ad_rspec = RSpec(infile)
ad_rspec = RSpec(infile)
-nodes =
file
(command.opts.nodefile).read().split()
+nodes =
open
(command.opts.nodefile).read().split()
version_manager = VersionManager()
try:
type = ad_rspec.version.type
version_manager = VersionManager()
try:
type = ad_rspec.version.type
diff --git
a/flashpolicy/sfa_flashpolicy.py
b/flashpolicy/sfa_flashpolicy.py
index
1fe3f84
..
f4d3f16
100644
(file)
--- a/
flashpolicy/sfa_flashpolicy.py
+++ b/
flashpolicy/sfa_flashpolicy.py
@@
-50,7
+50,7
@@
class policy_server(object):
self.sock.bind(('', port))
self.sock.listen(5)
def read_policy(self, path):
self.sock.bind(('', port))
self.sock.listen(5)
def read_policy(self, path):
- with
file
(path, 'rb') as f:
+ with
open
(path, 'rb') as f:
policy = f.read(10001)
if len(policy) > 10000:
raise exceptions.RuntimeError('File probably too large to be a policy file',
policy = f.read(10001)
if len(policy) > 10000:
raise exceptions.RuntimeError('File probably too large to be a policy file',
diff --git
a/sfa/client/manifolduploader.py
b/sfa/client/manifolduploader.py
index
a9dd29d
..
3b9de16
100755
(executable)
--- a/
sfa/client/manifolduploader.py
+++ b/
sfa/client/manifolduploader.py
@@
-164,7
+164,7
@@
def main ():
logger=sfi_logger)
for filename in args.credential_files:
logger=sfi_logger)
for filename in args.credential_files:
- with
file
(filename) as f:
+ with
open
(filename) as f:
result=uploader.upload (f.read(),filename)
sfi_logger.info('... result=%s'%result)
result=uploader.upload (f.read(),filename)
sfi_logger.info('... result=%s'%result)
diff --git
a/sfa/client/sfaclientlib.py
b/sfa/client/sfaclientlib.py
index
ebadb01
..
b7114be
100644
(file)
--- a/
sfa/client/sfaclientlib.py
+++ b/
sfa/client/sfaclientlib.py
@@
-306,15
+306,12
@@
class SfaClientBootstrap:
# return Credential(filename=self.my_credential()).save_to_string()
# but in order to make it simpler to other implementations/languages..
def plain_read(self, filename):
# return Credential(filename=self.my_credential()).save_to_string()
# but in order to make it simpler to other implementations/languages..
def plain_read(self, filename):
- infile = file(filename, "r")
- result = infile.read()
- infile.close()
- return result
+ with open(filename) as infile:
+ return infile.read()
def plain_write(self, filename, contents):
def plain_write(self, filename, contents):
- outfile = file(filename, "w")
- result = outfile.write(contents)
- outfile.close()
+ with open(filename, "w") as outfile:
+ outfile.write(contents)
def assert_filename(self, filename, kind):
if not os.path.isfile(filename):
def assert_filename(self, filename, kind):
if not os.path.isfile(filename):
@@
-337,7
+334,7
@@
class SfaClientBootstrap:
def wrap(f):
def wrapped(self, *args, **kw):
filename = filename_method(self, *args, **kw)
def wrap(f):
def wrapped(self, *args, **kw):
filename = filename_method(self, *args, **kw)
- if os.path.isfile(
filename
):
+ if os.path.isfile(
filename
):
if not validate_method:
return filename
elif validate_method(self, filename):
if not validate_method:
return filename
elif validate_method(self, filename):
diff --git
a/sfa/client/sfascan.py
b/sfa/client/sfascan.py
index
d3ae2fd
..
136835d
100644
(file)
--- a/
sfa/client/sfascan.py
+++ b/
sfa/client/sfascan.py
@@
-51,7
+51,7
@@
class VersionCache:
def load (self):
try:
def load (self):
try:
- infile=
file
(self.filename,'r')
+ infile=
open
(self.filename,'r')
self.url2version=pickle.load(infile)
infile.close()
except:
self.url2version=pickle.load(infile)
infile.close()
except:
@@
-61,7
+61,7
@@
class VersionCache:
def save (self):
try:
def save (self):
try:
- outfile=
file
(self.filename,'w')
+ outfile=
open
(self.filename,'w')
pickle.dump(self.url2version,outfile)
outfile.close()
except:
pickle.dump(self.url2version,outfile)
outfile.close()
except:
diff --git
a/sfa/client/sfi.py
b/sfa/client/sfi.py
index
c0f1e41
..
95acf18
100644
(file)
--- a/
sfa/client/sfi.py
+++ b/
sfa/client/sfi.py
@@
-1776,7
+1776,7
@@
$ sfi m -b http://mymanifold.foo.com:7080/
filename = os.path.join( self.options.sfi_dir,
"{}.{}_for_{}.{}.cred"\
.format(hrn, htype, delegatee_hrn, delegatee_type))
filename = os.path.join( self.options.sfi_dir,
"{}.{}_for_{}.{}.cred"\
.format(hrn, htype, delegatee_hrn, delegatee_type))
- with
file
(filename, 'w') as f:
+ with
open
(filename, 'w') as f:
f.write(delegated_credential)
self.logger.debug("(Over)wrote {}".format(filename))
hrn_delegated_credentials.append((hrn, htype, delegated_credential, filename, ))
f.write(delegated_credential)
self.logger.debug("(Over)wrote {}".format(filename))
hrn_delegated_credentials.append((hrn, htype, delegated_credential, filename, ))
diff --git
a/sfa/trust/credential.py
b/sfa/trust/credential.py
index
c4795cc
..
6f5336d
100644
(file)
--- a/
sfa/trust/credential.py
+++ b/
sfa/trust/credential.py
@@
-299,7
+299,8
@@
class Credential(object):
if string:
str = string
elif filename:
if string:
str = string
elif filename:
- str = file(filename).read()
+ with open(filename) as infile:
+ str = infile.read()
# if this is a legacy credential, write error and bail out
if isinstance (str, StringType) and str.strip().startswith("-----"):
# if this is a legacy credential, write error and bail out
if isinstance (str, StringType) and str.strip().startswith("-----"):