def test_main(check_commits_mock, create_version_mock, download_tar, calc_sha256_mock, create_brew_mock, get_sha_mock, upload_mock, cleanup_mock, download_mock, verify_mock): assert publish.main() check_commits_mock.assert_called_once() create_version_mock.assert_called_once() download_tar.assert_called_once() calc_sha256_mock.assert_called_once() create_brew_mock.assert_called_once() get_sha_mock.assert_called_once() upload_mock.assert_called_once() cleanup_mock.assert_called_once() download_mock.assert_called_once() verify_mock.assert_called_once()
def main(): epoctime_mem = 0 while True: os.chdir(curdir) files = get_srcs(build_src_dirs) epoctime_new = 0 for file in files: update_time = file.stat().st_mtime epoctime_new += update_time # update_time = datetime.datetime.fromtimestamp(file.stat().st_mtime) # print(update_time) if epoctime_new != epoctime_mem: print("================================") print("epoctime_mem: ", epoctime_mem) print("epoctime_new: ", epoctime_new) epoctime_mem = epoctime_new print("--------------------------------") pp(files) print("--------------------------------") make_html.main() os.chdir(curdir) publish.main() dt = datetime.datetime.now() print("--------------------------------") print("Last build @ " + dt.strftime('%Y/%m/%d-%H:%M:%S')) print("Now watching ") pp(build_src_dirs) time.sleep(1)
def evaluate(sb, options): state = EvalState() phase_argv = ['--sandbox', sb.get_root()] with ioutil.WorkingDir(sb.get_root()) as td: with sb.lock('eval') as lock: try: try: if not options.no_update: with Phase(state, EvalPhase.UPDATE, lock) as phase: state.err = update(sb, lock) if not state.err: with Phase(state, EvalPhase.BUILD, lock) as phase: argv = get_build_phase_args(phase_argv, options) state.err = build.main(argv) if not state.err: with Phase(state, EvalPhase.TEST, lock) as phase: argv = get_test_phase_args(["test"], options) state.err = test.main(argv) if (not state.err) and sb.get_sandboxtype().get_should_publish(): with Phase(state, EvalPhase.PUBLISH, lock) as phase: state.err = publish.main(phase_argv) except: txt = traceback.format_exc() print(txt) # It is possible for us to get an exception as we try to enter # a phase (including the first one). In such a case, we need # to work extra hard to help the user understand what's wrong. txt = txt.replace('\r', '').replace('\n', '; ').replace(',', ' ') state.reason = 'exception in build process itself: ' + txt if not state.timestamps: state.timestamps.append(time.time()) state.phase = EvalPhase.UPDATE finally: if os.path.exists(os.path.join(sb.get_root(), 'notify.txt')): if (not sb.get_sandboxtype().get_notify_on_success()) and (not state.err): os.remove('%snotify.txt' % sb.get_root()) else: notify = open('%snotify.txt' % sb.get_root(), 'r') emails = notify.read() notify.close() body = '' if os.path.exists(os.path.join(sb.get_root(), 'eval-log.txt')): body = os.path.join(sb.get_root(), 'eval-log.txt') os.remove('%snotify.txt' % sb.get_root()) bi = buildinfo.BuildInfo() if state.err: status = 'Failed' else: status = 'Succeeded' subject = '%s build of %s on %s %s.' % (sb.get_variant(), sb.get_top_component(), bi.host, status) arguments = '--to %s --sender sadm --subject "%s" --host smtp.example.com --port 587' % (emails, subject) # TODO KIM TO CONF arguments += ' --username [email protected] --password password' # TODO KIM TO CONF if body: arguments += ' --body "%s"' % body os.system('python %s/buildscripts/mailout.py %s' % (sb.get_code_root(), arguments)) if not state.err: state.reason = '' if _should_report(sb, options): report(sb, state) else: print('Skipping report phase.') return state.err
def evaluate(sb, options): state = EvalState() phase_argv = ['--sandbox', sb.get_root()] with ioutil.WorkingDir(sb.get_root()) as td: with sb.lock('eval') as lock: try: try: if not options.no_update: with Phase(state, EvalPhase.UPDATE, lock) as phase: state.err = update(sb, lock) if not state.err: with Phase(state, EvalPhase.BUILD, lock) as phase: argv = get_build_phase_args(phase_argv, options) state.err = build.main(argv) if not state.err: with Phase(state, EvalPhase.TEST, lock) as phase: argv = get_test_phase_args(["test"], options) state.err = test.main(argv) if (not state.err ) and sb.get_sandboxtype().get_should_publish(): with Phase(state, EvalPhase.PUBLISH, lock) as phase: state.err = publish.main(phase_argv) except: txt = traceback.format_exc() print(txt) # It is possible for us to get an exception as we try to enter # a phase (including the first one). In such a case, we need # to work extra hard to help the user understand what's wrong. txt = txt.replace('\r', '').replace('\n', '; ').replace(',', ' ') state.reason = 'exception in build process itself: ' + txt if not state.timestamps: state.timestamps.append(time.time()) state.phase = EvalPhase.UPDATE finally: if os.path.exists(os.path.join(sb.get_root(), 'notify.txt')): if (not sb.get_sandboxtype().get_notify_on_success()) and ( not state.err): os.remove('%snotify.txt' % sb.get_root()) else: notify = open('%snotify.txt' % sb.get_root(), 'r') emails = notify.read() notify.close() body = '' if os.path.exists( os.path.join(sb.get_root(), 'eval-log.txt')): body = os.path.join(sb.get_root(), 'eval-log.txt') os.remove('%snotify.txt' % sb.get_root()) bi = buildinfo.BuildInfo() if state.err: status = 'Failed' else: status = 'Succeeded' subject = '%s build of %s on %s %s.' % (sb.get_variant( ), sb.get_top_component(), bi.host, status) arguments = '--to %s --sender sadm --subject "%s" --host smtp.example.com --port 587' % ( emails, subject) # TODO KIM TO CONF arguments += ' --username [email protected] --password password' # TODO KIM TO CONF if body: arguments += ' --body "%s"' % body os.system('python %s/buildscripts/mailout.py %s' % (sb.get_code_root(), arguments)) if not state.err: state.reason = '' if _should_report(sb, options): report(sb, state) else: print('Skipping report phase.') return state.err
time.sleep(3) files = glob.glob(path_to_watch + '*.csv') after = dict([(f, None) for f in os.listdir(path_to_watch)]) added = [f for f in after if not f in before] removed = [f for f in before if not f in after] if added: print("Added: ", ", ".join(added)) for file in files: file_name = os.path.basename(file) file_name_array = file_name.split("_") last_item = file_name_array[-1] df = pd.read_csv(file) row_count = df.shape[0] if last_item == "DHT.csv": logging.info( "Watching the directory: %s for dht11 sensor csv file having 2 rows in it" % PUB_DUMP_DIR) if row_count == DHT_ROW_COUNT: publish.main(file_name) print("publish") else: logging.info( "Watching the directory: %s for csv file having 15000 rows in it" % PUB_DUMP_DIR) if row_count == ROW_COUNT: publish.main(file_name) print("publish") before = after