# Path: database.py
# def init_db():


import os
import sys
import time
import subprocess
import settings
from datetime import datetime
from database import db_session
from models import *
#!/usr/bin/env python

sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir))

def get_latest_remote_version(repo_url):
    cmd = 'git ls-remote {} master | grep refs/heads/master | cut -f1'.format(repo_url)
    try:
        version = subprocess.check_output(cmd, shell=True).strip()
    except:
        return False
    if len(version) != 40:
        return False
    return version


def do_compiler(compiler):
    version_sha = get_latest_remote_version(compiler.repo_url)
    compiler.last_check_time = datetime.utcnow()
    db_session.commit()
    if not version_sha:
        return
    newer = False
    if compiler.latest_version_id:

# Path: database.py
# def init_db():


# Path: core/repo_watcher.py
import os
import sys
import time
import subprocess
import settings
from datetime import datetime
from database import db_session
from models import *

#!/usr/bin/env python

sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir))

def get_latest_remote_version(repo_url):
    cmd = 'git ls-remote {} master | grep refs/heads/master | cut -f1'.format(repo_url)
    try:
        version = subprocess.check_output(cmd, shell=True).strip()
    except:
        return False
    if len(version) != 40:
        return False
    return version


def do_compiler(compiler):
    version_sha = get_latest_remote_version(compiler.repo_url)
    compiler.last_check_time = datetime.utcnow()
    db_session.commit()
    if not version_sha:
        return
    newer = False
    if compiler.latest_version_id:

        version = db_session.query(Version)\