Skip to content

Commit

Permalink
update scan and update to deal with changes to local files
Browse files Browse the repository at this point in the history
  • Loading branch information
holtzermann17 committed Oct 14, 2015
1 parent c8d8ef4 commit 73d3cf4
Showing 1 changed file with 28 additions and 12 deletions.
40 changes: 28 additions & 12 deletions scan-and-update.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
p = subprocess.Popen(["git", "pull"],cwd="/bibserver/ims_legacy/BibProject/")
p.wait()

# After checking out the material from Github, we can see whether any of those files changed.
# This will include material that has been modified by the IMS editor by hand
# (As well as anything from the distributed update that has been pulled in.)
changed_tex_files = subprocess.Popen(["git", "diff-index", "--name-only", "HEAD~1"],cwd="/bibserver/ims_legacy/BibProject/",stdout=subprocess.PIPE).communicate()[0].splitlines()

# A checked out version of miniBibServer
lib_path = os.path.abspath('/bibserver/ims_legacy/miniBibServer/')
sys.path.append(lib_path)
Expand All @@ -40,32 +45,39 @@
# import ims_sources
## and instead we run this:

# Double check (debugging code)
print "Changed tex files:"
pprint(changed_tex_files)

import read_member_index
urllist = read_member_index.read_member_index()

def check_local (source):
"""We may eventually do something interesting but for now, this does nothing."""
return True

## Now go through this script, which works as follows:

## Step 1: download copies of all files in our list

## Step 2: compare downloaded files to local copies

local_commit_flag = False

for item in urllist:
member_id=item[0]
# print "person name: " + member_id
source=item[1]
# Maybe the only thing to do in this case is produce some new HTML,
# assuming we keep "staged" and "working" copies separate. But as
# a first step, let's assume there's nothing to do in this case, and
# we just need to process the upstream files.
# print source[:11]
# The only thing to do when the member's information is stored in the Git repository is to produce some new HTML
if (source[:11] == "./tex_files"):
upstream_filename = urllib2.unquote(source.rsplit("/",1)[1])
# at the moment this does nothing
check_local(source)
relative_path = source[2:]
# check that the path is correct; we might want 'source' here.
if (relative_path not in changed_tex_files):
print relative_path + " is not in list of changed tex files."
break
else:
local_filename = "/bibserver/ims_legacy/BibProject/tex_files/" + member_id + ".tex"
htmlcontent = ims_legacy.make_one(local_filename)
distributed_update.make_commit("master","new_html_files",member_id + ".html",htmlcontent)
with open("/bibserver/ims_legacy/WorkingDirectory/"+member_id+".json", "r") as f:
jsonstring = f.read()
distributed_update.make_commit("master","json_files",member_id + ".json",jsonstring)
else:
upstream_filename = urllib2.unquote(source.rsplit("/",1)[1])

Expand Down Expand Up @@ -131,4 +143,8 @@ def check_local (source):
else:
sys.stdout.write('.')

# If we've prepared any commits changing HTML files, then we should
# push them... Oh wait, actually the commits are just made directly
# without need to push. Let's see if this works.

print "done."

0 comments on commit 73d3cf4

Please sign in to comment.