예제 #1
0
파일: __init__.py 프로젝트: wpjunior/proled
 def run(self):
     # the mainloop.
     try:
         import ZServer
         import Lifetime
         Lifetime.loop()
         sys.exit(ZServer.exit_code)
     finally:
         self.shutdown()
예제 #2
0
 def shutdown(signum, frame, signum_set=set()):
     Lifetime.shutdown(0)
     signum_set.add(signum)
     if node_pid_list is None and len(signum_set) > 1:
         # in case of ^C, a child should also receive a SIGHUP from the parent,
         # so we merge the first 2 different signals in a single exception
         signum_set.remove(signal.SIGHUP)
     else:
         raise KeyboardInterrupt
예제 #3
0
 def shutdown(signum, frame, signum_set=set()):
   Lifetime.shutdown(0)
   signum_set.add(signum)
   if node_pid_list is None and len(signum_set) > 1:
     # in case of ^C, a child should also receive a SIGHUP from the parent,
     # so we merge the first 2 different signals in a single exception
     signum_set.remove(signal.SIGHUP)
   else:
     raise KeyboardInterrupt
예제 #4
0
 def manage_shutdown(self, REQUEST=None):
     """Shut down the application"""
     try:
         user = '******' % getSecurityManager().getUser().getUserName()
     except:
         user = '******'
     LOG.info("Shutdown requested by %s" % user)
     #for db in Globals.opened: db.close()
     Lifetime.shutdown(0)
     return """<html>
예제 #5
0
 def manage_shutdown(self, REQUEST=None):
     """Shut down the application"""
     try:
         user = '******' % getSecurityManager().getUser().getUserName()
     except:
         user = '******'
     logger.info("Shutdown requested by %s" % user)
     #for db in Globals.opened: db.close()
     Lifetime.shutdown(0)
     return """<html>
예제 #6
0
 def run(self):
     # the mainloop.
     try:
         from App.config import getConfiguration
         config = getConfiguration()  # NOQA
         import Lifetime
         Lifetime.loop()
         from ZServer.Zope2.Startup.config import ZSERVER_EXIT_CODE
         sys.exit(ZSERVER_EXIT_CODE)
     finally:
         self.shutdown()
예제 #7
0
 def run(self):
     # the mainloop.
     try:
         from App.config import getConfiguration
         config = getConfiguration()
         import ZServer
         import Lifetime
         Lifetime.loop()
         sys.exit(ZServer.exit_code)
     finally:
         self.shutdown()
예제 #8
0
 def run(self):
     # the mainloop.
     try:
         from App.config import getConfiguration
         config = getConfiguration()  # NOQA
         import Lifetime
         Lifetime.loop()
         from ZServer.Zope2.Startup.config import ZSERVER_EXIT_CODE
         sys.exit(ZSERVER_EXIT_CODE)
     finally:
         self.shutdown()
예제 #9
0
 def manage_restart(self, URL1, REQUEST=None):
     """Shut down the application"""
     try:
         user = '******' % getSecurityManager().getUser().getUserName()
     except:
         user = '******'
     LOG.info("Restart requested by %s" % user)
     #for db in Globals.opened: db.close()
     Lifetime.shutdown(1)
     return """<html>
     <head><meta HTTP-EQUIV=REFRESH CONTENT="10; URL=%s/manage_main">
     </head>
     <body>Zope is restarting</body></html>
     """ % escape(URL1, 1)
예제 #10
0
 def manage_restart(self, URL1, REQUEST=None):
     """Shut down the application"""
     try:
         user = '******' % getSecurityManager().getUser().getUserName()
     except:
         user = '******'
     logger.info("Restart requested by %s" % user)
     #for db in Globals.opened: db.close()
     Lifetime.shutdown(1)
     return """<html>
     <head><meta HTTP-EQUIV=REFRESH CONTENT="10; URL=%s/manage_main">
     </head>
     <body>Zope is restarting</body></html>
     """ % escape(URL1, 1)
    def signalHandler(self, signum, frame):
        """Meta signal handler that dispatches to registered handlers."""
        signame = get_signal_name(signum)
        logger.info("Caught signal %s" % signame)

        for handler in self.registry.get(signum, []):
            # Never let a bad handler prevent the standard signal
            # handlers from running.
            try: handler()
            except SystemExit, rc:
                # On Unix, signals are delivered to the main thread, so a 
                # SystemExit does the right thing.  On Windows, we are on
                # our own thread, so throwing SystemExit there isn't a great
                # idea.  Just shutdown the main loop.
                logger.debug("Trapped SystemExit(%s) - doing Lifetime shutdown" % (rc,))
                Lifetime.shutdown(rc)
            except:
예제 #12
0
    def signalHandler(self, signum, frame):
        """Meta signal handler that dispatches to registered handlers."""
        signame = get_signal_name(signum)
        logger.info("Caught signal %s" % signame)

        for handler in self.registry.get(signum, []):
            # Never let a bad handler prevent the standard signal
            # handlers from running.
            try:
                handler()
            except SystemExit, rc:
                # On Unix, signals are delivered to the main thread, so a
                # SystemExit does the right thing.  On Windows, we are on
                # our own thread, so throwing SystemExit there isn't a great
                # idea.  Just shutdown the main loop.
                logger.debug(
                    "Trapped SystemExit(%s) - doing Lifetime shutdown" %
                    (rc, ))
                Lifetime.shutdown(rc)
            except:
def ERP5Site_restartZopeInstance(self):
  """
    Zope must be restart after update the Products or Software
    But the restart into one activity, will make the activity always
    fail and with the server will be restart many times.

    This method use a flag to define if the server was already restarted.
    If yes, the flag is removed and the restart will be ignored.

    This method should be run into a single activity to prevent rollback
    other parts.
  """
  import Lifetime
  Lifetime.shutdown(1,fast=1)
  log("Zope Restart was launched.")

  active_result = ActiveResult()
  active_result.edit(summary="Zope Restart",
                     severity=0,
                     detail="Zope was restart Sucessfully.")
  return active_result
예제 #14
0
def ERP5Site_restartZopeInstance(self):
    """
    Zope must be restart after update the Products or Software
    But the restart into one activity, will make the activity always
    fail and with the server will be restart many times.

    This method use a flag to define if the server was already restarted.
    If yes, the flag is removed and the restart will be ignored.

    This method should be run into a single activity to prevent rollback
    other parts.
  """
    import Lifetime
    Lifetime.shutdown(1, fast=1)
    log("Zope Restart was launched.")

    active_result = ActiveResult()
    active_result.edit(summary="Zope Restart",
                       severity=0,
                       detail="Zope was restart Sucessfully.")
    return active_result
예제 #15
0
파일: ibs_calc.py 프로젝트: dtbinh/code
def calc_ibs(param, twiss, I0, print_flag=False):

    #Definition of mA
    #mA=1e-3/param['Ccoul']*param['C']/param['cluz']

    #Define new vectors
    Np = _np.zeros(1)
    exi = _np.zeros(1)
    eyi = _np.zeros(1)
    spi = _np.zeros(1)
    ssi = _np.zeros(1)
    LFtous = _np.zeros(1)
    LFine = _np.zeros(1)
    LFelas = _np.zeros(1)

    if print_flag:
        print('-----------------------------------------------')
        print('Calculates IBS effects and Lifetime results')
    #Calculates IBS effects on the emittances
    (exi[0], eyi[0], spi[0],
     ssi[0]) = _cimp_3hc.Iterate_emittances(twiss, param)
    #Uses the IBS results to calculates lifetimes
    (LFtous[0], LFine[0],
     LFelas[0]) = _lifetime.Calc_Lifetime(param, I0, twiss, exi[0], eyi[0],
                                          spi[0], ssi[0])
    if print_flag:
        print('Bunch number = {0}'.format(0 + 1))
        print('Ib = {0:4.1f} mA'.format(I0[0]))
        print('ex_fim = {0:0.3f} nm rad'.format(exi[0] * 1e9))
        print('ey_fim = {0:0.3f} pm rad'.format(eyi[0] * 1e12))
        print('sp_fim = {0:0.3f} %'.format(spi[0] * 100))
        print('ss_fim = {0:0.3f} mm or {1:0.3f} ps'.format(
            ssi[0] * 1e3, ssi[0] / param['cluz'] * 1e12))
        print(
            'Lifetime results [h]: Touschek = {0:0.2f}, Elastic = {1:0.2f} and Inelastic  = {2:0.2f}'
            .format(LFtous[0], LFelas[0], LFine[0]))
    if print_flag:
        print('-----------------------------------------------')
        print('\n')

    param['Ib'] = I0
    param['ex_fim'] = exi
    param['ey_fim'] = eyi
    param['sp_fim'] = spi
    param['ss_fim'] = ssi
    param['lft_tous'] = LFtous
    param['lft_elas'] = LFelas
    param['lft_ine'] = LFine

    return param
예제 #16
0
 def run(self):
     # the mainloop.
     try:
         from App.config import getConfiguration
         config = getConfiguration()
         import ZServer
         if config.twisted_servers and config.servers:
             raise ZConfig.ConfigurationError(
                 "You can't run both ZServer servers and twisted servers.")
         if config.twisted_servers:
             if not _use_twisted:
                 raise ZConfig.ConfigurationError(
                     "You do not have twisted installed.")
             twisted.internet.reactor.run()
             # Storing the exit code in the ZServer even for twisted,
             # but hey, it works...
             sys.exit(ZServer.exit_code)
         else:
             import Lifetime
             Lifetime.loop()
             sys.exit(ZServer.exit_code)
     finally:
         self.shutdown()
예제 #17
0
 def tearDown(self):
     Lifetime.shutdown(0, fast=1)
예제 #18
0
 def asyncore_loop():
     try:
         Lifetime.lifetime_loop()
     except KeyboardInterrupt:
         pass
     Lifetime.graceful_shutdown_loop()
 def asyncore_loop():
     try:
         Lifetime.lifetime_loop()
     except KeyboardInterrupt:
         pass
     Lifetime.graceful_shutdown_loop()
예제 #20
0
파일: Signals.py 프로젝트: tseaver/Zope-RFA
def shutdownFastHandler():
    """Shutdown cleanly on SIGTERM. This is registered first,
       so it should be called after all other handlers."""
    logger.info("Shutting down fast")
    Lifetime.shutdown(0, fast=1)
예제 #21
0
파일: Signals.py 프로젝트: tseaver/Zope-RFA
def restartHandler():
    """Restart cleanly on SIGHUP. This is registered first, so it
       should be called after all other SIGHUP handlers."""
    logger.info("Restarting")
    Lifetime.shutdown(1)
예제 #22
0
파일: Signals.py 프로젝트: wpjunior/proled
def restartHandler():
    """Restart cleanly on SIGHUP. This is registered first, so it
       should be called after all other SIGHUP handlers."""
    logger.info("Restarting")
    Lifetime.shutdown(1)
예제 #23
0
파일: Signals.py 프로젝트: wpjunior/proled
def shutdownFastHandler():
    """Shutdown cleanly on SIGTERM. This is registered first,
       so it should be called after all other handlers."""
    logger.info("Shutting down fast")
    Lifetime.shutdown(0,fast=1)