Пример #1
0
        return self.writeflag


# --------------------------------------
# --------------------------------------
# now do it
try:
    for i in target:
        if mode == "domain":
            ip = aprs[domains[i]["apr"]]["ip"]
        else:
            ip = aprs[i]["ip"]
        cmd(ip, port, mode, i, command)

    # ---------------------------
    sock.loop()

    # ---------------------------
    for i in target:
        if i not in responses:
            if mode == "domain":
                ip = aprs[domains[i]["apr"]]["ip"]
            else:
                ip = aprs[i]["ip"]
            print "%s (%s): not responding" % (i, ip)
            log.l.LogIt("CMD013", "E", "%s (%s): not responding", (i, ip))

    log.l.LogIt("CMD014", "I", "stop", ())

except Exception, why:
    log.l.LogIt("CMD015", "F", "program exception: %s", (str(why)))
Пример #2
0
  #---------------------------
  # check if DAS mode, if so update our data
  findcmd = 'find ' + srvcfg.dasPath
  last = srvcfg.dasFiles[-1]
  for i in srvcfg.dasFiles:
    findcmd += ' -name "' + i + '"'
    if i != last:
      findcmd += ' -o'
  
  f = os.popen(findcmd)
  files =f.readlines()
  f.close()

  if srvgl.das_mode != len(files):
    srvgl.das_mode = len(files)
    log.l.LogIt('RS0018', 'I', 'DAS %d', (srvgl.das_mode))

#------------------------------------------------
try:
  srvcmd_hdlr.srvcmd(host, cmdport)
  srvcfg_hdlr.srvcfg(host, srvport)

  sock.loop(srvcfg.Poll, poll)

except Exception, why:
  log.l.LogIt('RS0019', 'F', 'program exception: %s', (str(why)))
  raise

#------------------------------------------------
Пример #3
0
  server = socket.gethostbyname(socket.gethostname())
  port = int(sys.argv[2])
  tcpip = 0

# Local log
log.l = log.PathFmtLogFile(progname+wsid, 'n', -1, 50*1024, 10, TraceLevel=0)
log.l.LogIt('GA0001', 'I', 'start - WSID: %s', (wsid))

# Handle signals
def sig_end(signum, frame):
  log.l.LogIt('GA0002', 'W', 'signal %d termination', (signum))
  sys.exit(1)

signal.signal(signal.SIGINT, sig_end)
signal.signal(signal.SIGTERM, sig_end)
signal.signal(signal.SIGHUP, signal.SIG_IGN)

#------------------------------------------------
try:
  while 1:

    # connect to BNM Server
    ga_tcphdlr.ga(server, port, wsid)
    sock.loop(5)
    log.l.LogIt('GA0003', 'W', 'sleep 5 seconds', ())
    time.sleep(5)
except Exception, why:
  log.l.LogIt('GA0004', 'F', 'program exception: %s', (str(why)))
  raise
#------------------------------------------------
Пример #4
0
 
  def writable(self):
    return len(self.senddata)

#-----------------------------------------------------------
#-----------------------------------------------------------
#-----------------------------------------------------------
if option == 'srv':
  """
  Program runs on the BNM Server.
  """
  ver.showVersion(progname, lversion, rcsid)
  print time.asctime(time.localtime(time.time()))
  sys.stdout.flush()
  reciever(host, portsrv)
  sock.loop(10, sys.stdout.flush())

#--------------------------------------
if option == 'apr':
  """
  Program runs on the APR.
  """
  ver.showVersion(progname, lversion, rcsid)
  print time.asctime(time.localtime(time.time()))
  sys.stdout.flush()
  reciever(host, portapr)
  for ip in servers.keys():
    sender(ip, portsrv)
  sock.loop(60, reconnect)

#--------------------------------------
Пример #5
0
  def handle_close(self):
    log.l.LogIt('CTL022', '1', 'close cmd', ())
    self.close()

  def writable(self):
    return len(self.senddata)

#------------------------------------------------
#------------------------------------------------
try:

  # Listen for connections from 'aprctrl's
  cmdobj = cmd()	# to be able to close it

  sock.loop(20, sys.stdout.flush())

  if poweroff:
    if os.getuid() == 0 or os.geteuid() == 0:
      os.system('/sbin/poweroff')
      while 1:
        pass
    else:
      log.l.LogIt('CTL023', 'I', 'not authorized to poweroff', ())

  if reboot:
    if os.getuid() == 0 or os.geteuid() == 0:
      os.system('/sbin/reboot')
      while 1:
        pass
    else:
Пример #6
0
list = cfg.servers.keys()
list.sort()
for ip in list:
    if not cfg.servers[ip]["cmdchan"]:
        srv_hdlr.srv(ip)
    if not cfg.servers[ip]["routc"]:
        routc_hdlr.bnmroutc(ip)

# ------------------------------------------------
try:

    # Listen for connections from 'aprcmd's
    cmd_hdlr.cmd()

    # Set SNA Server connect flag
    try:
        f = open("/router/snasrv/snasrv", "r")
        f.close()
        cfg.sna_use = 1
    except:
        cfg.sna_use = 0

    sock.loop(1, poll.poll)  # call callback every second

except Exception, why:
    log.l.LogIt("RT0003", "F", "program exception: %s", (str(why)))
    raise

sys.exit(0)
# ------------------------------------------------