def pid_file(pid_path=None, pid_file=None, port=0):
 global DIR_PID
 if (not sabnzbd.WIN32):
  if (pid_path and pid_path.startswith('/')):
   DIR_PID = os.path.join(pid_path, ('sabnzbd-%s.pid' % port))
  elif (pid_file and pid_file.startswith('/')):
   DIR_PID = pid_file
 if DIR_PID:
  try:
   if port:
    f = open(DIR_PID, 'w')
    f.write(('%d\n' % os.getpid()))
    f.close()
   else:
    os.remove(DIR_PID)
  except:
   logging.warning('Cannot access PID file %s', DIR_PID)

def pid_file ( pid_path = None , pid_file = None , port = 0 ) : global DIR_PID if ( not sabnzbd . WIN32 ) : if ( pid_path and pid_path . startswith ( '/' ) ) : DIR_PID = os . path . join ( pid_path , ( 'sabnzbd-%s.pid' % port ) ) elif ( pid_file and pid_file . startswith ( '/' ) ) : DIR_PID = pid_file if DIR_PID : try : if port : f = open ( DIR_PID , 'w' ) f . write ( ( '%d\n' % os . getpid ( ) ) ) f . close ( ) else : os . remove ( DIR_PID ) except : logging . warning ( 'Cannot access PID file %s' , DIR_PID )
create or remove pid file .