Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
5bd95a95
Commit
5bd95a95
authored
Jun 14, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #474 from sfromm/issue471
Issue471 - import hashlib to sidestep deprecation warnings
parents
2b1b8d21
14dc12cd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
library/assemble
+15
-3
No files found.
library/assemble
View file @
5bd95a95
...
...
@@ -23,12 +23,17 @@ except ImportError:
import
simplejson
as
json
import
os
import
os.path
import
md5
import
sys
import
shlex
import
shutil
import
syslog
import
tempfile
try
:
import
hashlib
HAVE_HASHLIB
=
True
except
ImportError
:
import
md5
HAVE_HASHLIB
=
False
# Since hashlib is only available in 2.5 and onwards, this module
# uses md5 which is available in 2.4.
...
...
@@ -59,6 +64,13 @@ def write_temp_file(data):
os
.
close
(
fd
)
return
path
def
file_digest
(
path
):
if
HAVE_HASHLIB
:
digest
=
hashlib
.
md5
(
file
(
path
)
.
read
())
.
hexdigest
()
else
:
digest
=
md5
.
new
(
file
(
path
)
.
read
())
.
hexdigest
()
return
digest
# ===========================================
if
len
(
sys
.
argv
)
==
1
:
...
...
@@ -99,10 +111,10 @@ if not os.path.isdir(src):
fail_json
(
msg
=
"Source (
%
s) is not a directory"
%
src
)
path
=
write_temp_file
(
assemble_from_fragments
(
src
))
pathmd5
=
md5
.
new
(
file
(
path
)
.
read
())
.
hexdigest
(
)
pathmd5
=
file_digest
(
path
)
if
os
.
path
.
exists
(
dest
):
destmd5
=
md5
.
new
(
file
(
dest
)
.
read
())
.
hexdigest
(
)
destmd5
=
file_digest
(
dest
)
if
pathmd5
!=
destmd5
:
shutil
.
copy
(
path
,
dest
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment