コード例 #1
0
ファイル: api.py プロジェクト: winbotscript/JeBB
 def __init__(self, client):
     object.__init__(self)
     self.timeout = 1000
     self.client = client
     self._1session = Session()
     self.lock = Lock()
     self._1sessionLock = Lock()
コード例 #2
0
ファイル: chatrooms.py プロジェクト: winbotscript/JeBB
 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()
コード例 #3
0
 def __init__(self):
     self.lock = Lock()
     self.uId = None
     self.rId = None
     self.templates = {}
     self.count = 0
     self.names = []
     self.byDesc = []
コード例 #4
0
ファイル: twentyfour.py プロジェクト: winbotscript/JeBB
 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)
コード例 #5
0
ファイル: twentyfour2.py プロジェクト: winbotscript/JeBB
 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
コード例 #6
0
ファイル: chatrooms.py プロジェクト: winbotscript/JeBB
 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
コード例 #7
0
ファイル: database.py プロジェクト: winbotscript/JeBB
    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)
コード例 #8
0
ファイル: database.py プロジェクト: winbotscript/JeBB
 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)
コード例 #9
0
ファイル: chatrooms.py プロジェクト: winbotscript/JeBB
 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)
コード例 #10
0
ファイル: thriftclientpool.py プロジェクト: winbotscript/JeBB
 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
コード例 #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
コード例 #12
0
ファイル: chatrooms.py プロジェクト: winbotscript/JeBB
 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)
コード例 #13
0
ファイル: twentyfour2.py プロジェクト: winbotscript/JeBB
        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,
コード例 #14
0
ファイル: chatrooms.py プロジェクト: winbotscript/JeBB
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)