Exemplo n.º 1
0
 def __init__(self, client):
     object.__init__(self)
     self.timeout = 1000
     self.client = client
     self._1session = Session()
     self.lock = Lock()
     self._1sessionLock = Lock()
Exemplo n.º 2
0
 def __init__(self, id=None, client=None, mid=None):
     self.id = id
     self.client = client
     self.mid = mid
     self._2hasUser = False
     self._2hasOA = False
     self.type = Type.chatroom
     self.lock = Lock()
     self.oLock = Lock()
     self._1time = 0
     self._1name = None
     self._3id = None
     self.key = None
     self._1gettingObj = False
     self.objCond = Condition()
Exemplo n.º 3
0
 def __init__(self):
     self.lock = Lock()
     self.uId = None
     self.rId = None
     self.templates = {}
     self.count = 0
     self.names = []
     self.byDesc = []
Exemplo n.º 4
0
 def __init__(self, obj, top=None, bot=None, addAtExit=True):
     self.obj = obj
     self.nums = None
     self.lock = Lock()
     self.top = 13
     self.bot = 1
     self.lastGenerated = 0
     if addAtExit:
         AddAtExit(self, self.__del__)
     self.Set(top, bot)
Exemplo n.º 5
0
 def __init__(self, room, obj):
     self.obj = obj
     self.room = room
     self.score = 0
     self.pendingScore = 0
     self.lock = Lock()
     with self.room.lock:
         self.room.lastPlayerId += 1
         self.id = self.room.lastPlayerId
         self.room.waitings.append((obj, self))
         self.room.playersByObj[obj] = self
         self.room.playersById[self.id] = self
Exemplo n.º 6
0
 def __init__(self):
     self.lock = Lock()
     self._1name = None
     self._1status = None
     self._1statusMessage = None
     self._1picUrl = None
     self._1relation = None
     self._1status = None
     self._1capableBuddy = None
     self._1userType = None
     self.type = Type.profile
     self.time = 0
Exemplo n.º 7
0
    def __init__(self, db, conn=None):
        self.cur = None
        self.conn = None
        self.lock = Lock()

        self.lastCmd = None

        self.alive = True
        self.ex = None
        self.commands = []
        self.db = db
        self.lastCmd = None
        self.RefreshConnection(conn, close=False)
Exemplo n.º 8
0
 def __init__(self, client, url):
     self.lock = Lock()
     with self.lock, client.lock:
         self.client = client
     with self.lock:
         self.connPool = []
         self.connCount = 0
         if version_info[0] < 3:
             urlparse.uses_netloc.append("postgres")
             self.url = urlparse.urlparse(url)
         else:
             urllib.parse.uses_netloc.append("postgres")
             self.url = urlparse(url)
Exemplo n.º 9
0
 def __init__(self, id=None, client=None, mid=None, init=True, rId=None):
     Chatroom.__init__(self, id, client, mid)
     self._1profile = Profile()
     self.rLock = Lock()
     self.rObjCond = Condition()
     self._3id = None
     self._1rId = None
     if rId is not None:
         self._1SetRId(rId)
     self._2hasUser = True
     self._2hasOA = True
     if init:
         self.client.Thread(self.GetProfile)
Exemplo n.º 10
0
 def __init__(self,
              client,
              url,
              protocol=TCompactProtocol,
              urlOut=None,
              timeout=1000):
     self.timeout = timeout
     self.client = client
     self.url = url
     self.lock = Lock()
     self._protocol = protocol
     self._clients = []
     self._allClients = []
     self._clientCount = 0
     self.timeout = 750
Exemplo n.º 11
0
 def __init__(self,
              client=None,
              message=None,
              url=None,
              bytes=None,
              hasOA=False,
              hasUser=False):
     self.lock = Lock()
     self._1message = message
     if client is None and message:
         client = message.client
     global defaultClient
     if client:
         defaultClient = client
     else:
         client = defaultClient
     self.client = client
     if url is None and id is not None and self.hasUser:
         url = "http://os.line.naver.jp/os/m/" + str(id)
     self._1url = url
     self._1bytes = bytes
Exemplo n.º 12
0
 def __init__(self,
              id=None,
              client=None,
              mid=None,
              hasOA=False,
              hasUser=False,
              init=True,
              uId=None):
     Chatroom.__init__(self, id, client, mid)
     if hasUser is None:
         hasUser = False
     self._3id = None
     self.uLock = Lock()
     if uId:
         self._1SetUId(uId)
     else:
         self._1uId = None
     self._2hasOA = hasOA
     self._2hasUser = hasUser
     self._1members = []
     if init and self.hasUser:
         self.client.Thread(self.GetMembers)
Exemplo n.º 13
0
        self.RemoveLeavingPlayers()
        if self.round < self.rounds and len(self.players) > 1:
            return self.RoundStart()
        else:
            return self.GameOver()

    def GameOver(self):
        m = self.players[0].score
        self.SendText("Game over.\n%s" % '\n'.join(
            ("%s : %s" % (x.name, x.score)) for x in self.players))
        self.phase = RoomPhase.done
        self.nums = None
        self.Remove()


lock = Lock()


def TwentyFour2(message,
                options='',
                text='',
                continuous=CommandContinuousCallType.notContinuous,
                action='',
                top=None,
                bot=None,
                allowrevote=False,
                roundtime=60,
                rounds=5,
                votetime=30,
                explaintime=15,
                winpoint=1,
Exemplo n.º 14
0
from line2.models.types import Type, ChatroomType
from line2.utils import Lock, IsEmpty, Acquire
from threading import Condition
from time import time, sleep
from traceback import format_exc, print_exc, print_stack
from random import randint

rObjQueue = []
rObjCond = Condition()
rObjLock = Lock()


def QueueRObj(user):
    with rObjLock:
        if user not in rObjQueue:
            rObjQueue.append(user)
        with rObjCond:
            rObjCond.notifyAll()


def CreateRObj():
    with rObjCond:
        while True:
            while len(rObjQueue) == 0:
                rObjCond.wait()
            with rObjLock:
                user = rObjQueue.pop(0)
                if user.hasUser and user.client.hasOA and user.client.oAClient.obj:
                    l = [user, user.client.oAClient.obj]
                    ret = user.client.CreateRoom(l)
                    #ret = self.client.CreateGroup("RObj #%d" % self._2id, l)