Compare commits

...

4 commits

Author SHA1 Message Date
740a2705ee Merge branch 'master' of github.com:alberanid/diffido
* 'master' of github.com:alberanid/diffido:
  remove demo link
  fix #14: avoid crashing if storage directory is missing
2018-11-05 13:27:34 +01:00
c2f46ce802 remove demo site 2018-11-05 13:27:10 +01:00
fde269c0dd remove demo link 2018-11-02 08:27:41 +01:00
9f8c1c9387 fix #14: avoid crashing if storage directory is missing 2018-09-16 20:52:43 +02:00
2 changed files with 18 additions and 8 deletions

View file

@ -5,11 +5,6 @@ Spot the difference on the web.
Tired of clicking F5 waiting for a change on a web page? Define a list of pages to watch, and receive an email when something has changed.
# Demo
See [https://ismito.it:3210/](https://ismito.it:3210/) (you can only add \*.wikipedia.org pages, there)
## Install, run, develop and debug
## Docker

View file

@ -196,7 +196,17 @@ def run_job(id_=None, force=False, *args, **kwargs):
req_path = urllib.parse.urlparse(req.url).path
base_name = os.path.basename(req_path) or 'index.html'
def _commit(id_, filename, content, queue):
os.chdir('storage/%s' % id_)
try:
os.chdir('storage/%s' % id_)
except Exception as e:
logger.info('unable to move to storage/%s directory: %s; trying to create it...' % (id_, e))
_created = False
try:
_created = git_create_repo(id_)
except Exception as e:
logger.info('unable to move to storage/%s directory: %s; unable to create it' % (id_, e))
if not _created:
return False
current_lines = 0
if os.path.isfile(filename):
with open(filename, 'r') as fd:
@ -328,7 +338,8 @@ def get_history(id_, limit=None, add_info=False):
def _history(id_, limit, queue):
try:
os.chdir('storage/%s' % id_)
except:
except Exception as e:
logger.info('unable to move to storage/%s directory: %s' % (id_, e))
return queue.put(b'')
cmd = [GIT_CMD, 'log', '--pretty=oneline', '--shortstat']
if limit is not None:
@ -383,7 +394,11 @@ def get_diff(id_, commit_id='HEAD', old_commit_id=None):
:returns: information about the schedule and the diff between commits
:rtype: dict"""
def _history(id_, commit_id, old_commit_id, queue):
os.chdir('storage/%s' % id_)
try:
os.chdir('storage/%s' % id_)
except Exception as e:
logger.info('unable to move to storage/%s directory: %s' % (id_, e))
return queue.put(b'')
p = subprocess.Popen([GIT_CMD, 'diff', old_commit_id or '%s~' % commit_id, commit_id],
stdout=subprocess.PIPE)
stdout, _ = p.communicate()