print ('Like rebase-helper-fedmsg <package> <version>')
    sys.exit(1)

package = sys.argv[1]
version = sys.argv[2]

tmp = tempfile.mkdtemp(prefix='thn-', dir='/tmp')
rh_stuff = {}
url = 'http://pkgs.fedoraproject.org/cgit/{package}.git'.format(package=package)
try:
    import sh
    sh.git.clone(url, tmp)
except ImportError:
    pass

rh_upstream = UpstreamMonitoring()
rh_upstream.add_upstream_log_file()
rh_upstream.add_thn_info(tmp, package, version)
ret_code, rh_stuff = rh_upstream.process_thn()
if int(ret_code) == 0:
    print ('Rebase package %s to %s was SUCCESSFUL.' % (package, version))
else:
    ret_code = 1
    print ('Rebase package %s to %s FAILED. See for details.' % (package, version))

print ('Koji scratch build is available here: %s' % rh_stuff['build_log'][int(ret_code)])
print ('Information about patches:\n%s' % '\n'.join(rh_stuff['patches']))
print ('Available log files generated by rebase-helper are:\n%s' % '\n'.join(rh_stuff['logs']))
print ('Checkers %s' % rh_stuff['checkers'])
shutil.rmtree(tmp)