def clear_log_function():
		done_param = 0
        	while RUNNING:
			### This should copy the content of the log file to old log file and clear it at 12 UTC.
			if int(float(time.strftime("%H", time.gmtime()))) == 12 and done_param == 0:
				daily_logging_handler.handle_log_files(conf.outstream, conf.outstream_old)
				done_param = 1
			if done_param == 1 and int(float(time.strftime("%H", time.gmtime()))) > 12:
				done_param = 0

			time.sleep(600)
    def run(self):
        """
		
		"""
        done_param = 0
        global RUNNING
        RUNNING = True

        val = beating_heart.start_heartbeat(job_id=m_conf.scheduler_id)

        strat = or_strategy.defStrat()
        i = 0
        while RUNNING:
            strat.handle_next()

            #			if int(float(time.strftime("%H", time.gmtime()))) >= 9 and int(float(time.strftime("%H", time.gmtime()))) <= 16:
            #				time.sleep(scheduler_config.check_time_sleeping)
            #			else:
            #				time.sleep(scheduler_config.check_time)

            ### This should copy the content of the log file to old log file and clear it at 7 UTC.
            ## Moves nightly output til obs log.

            yesterday = datetime.datetime.now() - datetime.timedelta(days=1)
            folder_date = yesterday.strftime('%Y%m%d')
            output_log = "/home/obs/logs/scheduler_logs/" + str(
                folder_date) + "_obs.log"
            if int(float(time.strftime(
                    "%H", time.gmtime()))) == 9 and done_param == 0:
                daily_logging_handler.handle_log_files(
                    scheduler_config.outstream, output_log)
                done_param = 1
                #sys.exit("%s The scheduler was automatically stopped..." % clock.timename())
            if done_param == 1 and int(
                    float(time.strftime("%H", time.gmtime()))) > 9:
                done_param = 0

            if i % 1000 == 0:
                print clock.timename(), "The scheduler was alive"
                sys.stdout.flush()
            i += 1

            time.sleep(scheduler_config.check_time)
Exemple #3
0
                m3_exercise_performed = 1

                print clock.obstimeUT(), "Daily exercising of M3 is done"

            if done_isong_param == 1 and float(sun_alt_d) < float(0.0):
                done_isong_param = 0

            if calib_done_param == 1 and float(sun_alt_d) > float(
                    daily_config.calib_sun_alt):
                calib_done_param = 0
                m3_exercise_performed = 0

            ##### LOG is cleared
            if int(float(time.strftime(
                    "%H", time.gmtime()))) == 12 and done_log_param == 0:
                daily_logging_handler.handle_log_files(
                    daily_config.outstream, daily_config.outstream_old)
                done_log_param = 1

            if done_log_param == 1 and int(
                    float(time.strftime("%H", time.gmtime()))) > 12:
                done_log_param = 0

            if self.songwriter_email_send == 1 and int(
                    float(time.strftime("%H", time.gmtime()))) > 17:
                self.songwriter_email_send = 0

            time.sleep(60)  #


def main():
    """
Exemple #4
0
                    #	tmp_file.close()
                    #except Exception, e:
                    #	pass
                    #try:
                    #	exec_str = "scp /tmp/conductor_targets.txt [email protected]:/var/www/new_web_site/conductor_targets.txt"
                    #	os.popen(exec_str)
                    #except Exception, e:
                    #	print "Problem copying conductor targets to srf..."
                    #	print e
                else:
                    print clock.timename(
                    ), "The night looks to be perfectly covered!"

            if int(float(time.strftime(
                    "%H", time.gmtime()))) == 12 and done_log_param == 0:
                daily_logging_handler.handle_log_files(conf.outstream,
                                                       conf.outstream_old)
                done_log_param = 1
            if done_log_param == 1 and int(
                    float(time.strftime("%H", time.gmtime()))) > 12:
                done_log_param = 0
                self.daily_update = 0
                self.daily_sun_insert = 0

            process = psutil.Process(os.getpid())
            print("Memory used in percent : %0.3f" %
                  float(process.memory_percent()))

            if float(process.memory_percent()) > 60:
                send_song_mail.send_mail().sending_an_email(
                    reciever=["mads"],
                    sender="SONG_MS",
Exemple #5
0
                        print clock.timename(), e

                try:
                    update_song_database.update("coude_unit", [
                        "iodine_temp_set", "iodine_temp_read",
                        "iodine_heater_on"
                    ], [tmp_temp_set, tmp_temp_act, tmp_status],
                                                "coude_unit_id")
                except Exception, e:
                    print clock.timename(
                    ), "Could not insert or update the database: ", e

                if int(float(time.strftime(
                        "%H", time.gmtime()))) == 12 and done_param == 0:
                    daily_logging_handler.handle_log_files(
                        i2_write2db_config.outstream,
                        i2_write2db_config.outstream_old)
                    done_param = 1
                if done_param == 1 and int(
                        float(time.strftime("%H", time.gmtime()))) > 12:
                    done_param = 0

                ### Printing out the tmon temperatures once every minute.
                print clock.timename(), temperatures

            try:
                temperatures = tmon.get_tmon_temps()
            except Exception, e:
                print clock.timename(), e
                print clock.timename(), "Could not get tmon temperatures..."
					song_checker_handle.check_wind()
				except Exception,e:
					print clock.timename(), " Problem in check_wind()"
					print clock.timename(), e

			if song_monitor_config.mon_cooling_unit == 1:	# If the config file specifies it cooling unit checks will be carried out.
				try:
					song_checker_handle.check_cooler()
				except Exception,e:
					print clock.timename(), " Problem in check_cooler()"
					print clock.timename(), e


			### This should copy the content of the log file to old log file and clear it at 12 UTC.
			if int(float(time.strftime("%H", time.gmtime()))) == 12 and done_param == 0:
				daily_logging_handler.handle_log_files(song_monitor_config.outstream, song_monitor_config.outstream_old)
				done_param = 1
			if done_param == 1 and int(float(time.strftime("%H", time.gmtime()))) > 12:
				done_param = 0


			clock.TimeSleep2(song_monitor_config.monitor_sleep_time) 

		print clock.timename(), " The monitor daemon was stopped"
		print clock.timename(), " The while loop got a False signal... "
			
def main():
	"""
		@brief: This is the main part of the code that starts up everything else. 
	"""