Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 08:39:01

0001 import sys
0002 import time
0003 
0004 from pandacommon.pandalogger import logger_utils
0005 from pandacommon.pandautils.thread_utils import GenericThread
0006 from pandaserver.config import panda_config
0007 from pandaserver.configurator import Carbon as carbon_module
0008 from pandaserver.configurator.Carbon import CarbonEmissions
0009 
0010 # logger
0011 base_logger = carbon_module._logger
0012 
0013 
0014 # main
0015 def main(argv=tuple(), tbuf=None, **kwargs):
0016     requester_id = GenericThread().get_full_id(__name__, sys.modules[__name__].__file__)
0017 
0018     # instantiate TB
0019     if tbuf is None:
0020         from pandaserver.taskbuffer.TaskBuffer import taskBuffer
0021 
0022         taskBuffer.init(
0023             panda_config.dbhost,
0024             panda_config.dbpasswd,
0025             nDBConnection=1,
0026             useTimeout=True,
0027             requester=requester_id,
0028         )
0029     else:
0030         taskBuffer = tbuf
0031 
0032     # If no argument, call the basic configurator
0033     if len(argv) == 1:
0034         _logger = logger_utils.make_logger(base_logger, "Carbon")
0035         t1 = time.time()
0036         carbon_emissions = CarbonEmissions(taskBuffer=taskBuffer)
0037         carbon_emissions.run()
0038         t2 = time.time()
0039         _logger.debug(f"Carbon run took {t2 - t1}s")
0040 
0041     else:
0042         base_logger.error("Carbon module being called with wrong arguments. Use no arguments")
0043 
0044     # stop taskBuffer if created inside this script
0045     if tbuf is None:
0046         taskBuffer.cleanup(requester=requester_id)
0047 
0048 
0049 if __name__ == "__main__":
0050     main(argv=sys.argv)