예제 #1
0
    def __init__(self, covariatesfn, soilsamplesfn, uncthreshold = 1.0, outfns = None):
        self.__sigTimestampe = int(time.time()*1000) # in ms

        self.__tileRasterReader = gdalwrapper.tiledRasterReader(covariatesfn, xsize = conf.TILE_XSIZE, ysize = conf.TILE_YSIZE)
        self.__msrInts = np.copy(self.__tileRasterReader.measurement_level_ints)

        soilsamples = points.Points()
        t0 = time.time()
        soilsamples.readFromCSV(soilsamplesfn)
        conf.TIME_KEEPING_DICT['parts']['read'].append(time.time()-t0)
        ## Extract covairate values at sample locations, if missing in the sample file
        if soilsamples.covariates_at_points is None:
            soilsamples.covariates_at_points = np.zeros((soilsamples.size, self.__tileRasterReader.nbands))
            for i in range(soilsamples.size):
                t0 = time.time()
                soilsamples.covariates_at_points[i] = self.__tileRasterReader.extractByXY(soilsamples.xycoords[i][0], soilsamples.xycoords[i][1]).flatten()
                conf.TIME_KEEPING_DICT['parts']['read'].append(time.time()-t0)
        self.__soilsamples = soilsamples
        self.__uncthreshold = uncthreshold

        if outfns is None:
            soilmapfn = soilsamplesfn.replace('.csv', '_soilmap.tif')
            uncertmapfn = soilsamplesfn.replace('.csv', '_uncertmap.tif')
            self.__outfns = [soilmapfn, uncertmapfn]
        else:
            self.__outfns = outfns

        ## variables needed in predict_opencl_atom()
        self.__samples_stats_collected = False
        self.__samples_SD_evs = None
        self.__samples_X = None
        self.__sample_weights = None
        self.__sample_attributes = None
        self.__nrows_samples = None
예제 #2
0
    def __init__(self, username, client_id, token, channel):
        self.client_id = client_id
        self.token = token
        self.channel = '#' + channel


        # Get the channel id, we will need this for v5 API calls
        url = 'https://api.twitch.tv/kraken/users?login='******'Client-ID': client_id, 'Accept': 'application/vnd.twitchtv.v5+json'}
        r = requests.get(url, headers=headers).json()
        self.channel_id = r['users'][0]['_id']

        # Create IRC bot connection
        server = 'irc.chat.twitch.tv'
        port = 6667
        print (f'Connecting to {server} on port {port}...')
        irc.bot.SingleServerIRCBot.__init__(self, [(server, port, 'oauth:'+token)], username, username)

        self.points = points.Points()
        self.events = bot_events.BotEvents(self.connection, self.channel, self.points)
예제 #3
0
 def get_first_card(self, deck_cards, n):
     for i in range(n):
         self.card_list.append(*deck_cards.get_first_card(1))
     self.point = points.Points(self.card_list).point
예제 #4
0




##########
## main ##
##########
if __name__=="__main__":

	# インスタンス生成
	useTwitter = usetwitter.UseTwitter()
	useCV = usecv.UseCV()
	useSQL = usesql.UseSQL()
	useBurp = useburp.UseBurp()
	point = points.Points()

	if os.path.isfile("/home/pi/sif/cap/mirrordir/prod-jp.lovelive.ge.klabgames.net_main.php_battle_endRoom.json"):
#	if os.path.isfile("/home/pi/sif/cap/mirrordir/prod-jp.lovelive.ge.klabgames.net_main.php_challenge_finalize.json"):
#		useBurp.read_burplog(point)
#		point.showPoints()
#		useSQL.update_eventTable(point,"sm28")
#		point.tweetPoints(useTwitter)

#	if os.path.isfile("/home/pi/sif/cap/mirrordir/prod-jp.lovelive.ge.klabgames.net_main.php_secretbox_pon.json"):
#		useBurp.gatcha_bot(useSQL)

#	useSQL.update_statusTable(useTwitter.time_tweet,useTwitter.username)
#	useSQL.update_eventTable(useTwitter,"cf3")
#	tweet_lp(useTwitter)
예제 #5
0
class AbstractedlyListener(StreamListener):
    """ Let's stare abstractedly at the User Streams ! """
    # インスタンス生成
    useTwitter = usetwitter.UseTwitter()
    useCV = usecv.UseCV()
    useBurp = useburp.UseBurp()
    useSQL = usesql.UseSQL()
    point = points.Points()

    def on_status(self, status):
        # Ubuntuの時は気づかなかったんだけど、Windowsで動作確認してたら
        # created_atはUTC(世界標準時)で返ってくるので日本時間にするために9時間プラスする。
        status.created_at += timedelta(hours=9)
        print(u"{text}".format(text=status.text))
        print(u"{name}({screen}) {created} via {src}\n".format(
            name=status.author.name,
            screen=status.author.screen_name,
            created=status.created_at,
            src=status.source))

        dobu = 1
        UR_flug = 1
        SR_flug = 1

        if (status.text.find('@sif_notify_bot') >
                -1) and (status.text.find('RT') < 0):

            tweet = '@' + str(status.author.screen_name) + '\n'

            for num in range(0, 11):

                names = get_names(status.text)
                if isinstance(names, str):
                    rarity = get_rare("normal")
                else:
                    rarity = get_rare("alpaca")

                if (status.text.find('UR') >
                        -1) and (rarity == 1) and (random.randint(0, 1)):
                    rarity = 4
                if (status.text.find('SR') >
                        -1) and (rarity == 1) and (random.randint(0, 1)):
                    rarity = 3

                if rarity > 1:
                    tweet = tweet + '*'
                    dobu = 0
                elif (dobu == 1) and (num == 10):
                    ## SR確定
                    tweet = tweet + '*'
                    rarity = 2
                    dobu = 0

                member_id = 30
                while member_id > 27 and member_id < 52:

                    series = 0
                    if rarity > 1:
                        print str(
                            status.text.rsplit(' ', 1)[1].encode('utf-8'))
                        series = str(
                            status.text.rsplit(' ', 1)[1].encode('utf-8'))
                        if not ('編' in series):
                            series = 0

                    member_id = self.useSQL.rand_member(rarity, names, series)
                (member_info, member_url) = self.useSQL.get_member(member_id)

                tweet = tweet + str(member_info)
                tweet = tweet + '\n'

                filename = '/home/pi/sif/cap/manage_sif/icon' + str(
                    num) + '.gif'
                command = "wget '" + str(member_url) + "' -O " + filename
                check = commands.getoutput(command)


#				print check

            if dobu == 1:
                tweet = tweet + 'ド(・8・)ブ'
            tweet = tweet + "#スクフェス"
            print "tweet:" + tweet

            icons = []
            for i in range(0, 11):
                icons.insert(
                    i, "/home/pi/sif/cap/manage_sif/icon" + str(i) + ".gif")

            self.useCV.create_gacha_image(icons)

            self.useTwitter.post_tweet_image(
                status.id, tweet, '/home/pi/sif/cap/manage_sif/result.jpg')
예제 #6
0
class smgatcha:
	""" Let's stare abstractedly at the User Streams ! """
	# インスタンス生成
	useTwitter = usetwitter.UseTwitter()
	useCV = usecv.UseCV()
	useBurp = useburp.UseBurp()
	useSQL = usesql.UseSQL()
	useGatcha = usegatcha.UseGatcha()
	point = points.Points()

	def dogatcha(self, desc):
		# Ubuntuの時は気づかなかったんだけど、Windowsで動作確認してたら
		# created_atはUTC(世界標準時)で返ってくるので日本時間にするために9時間プラスする。

		dobu = 1
		UR_flug = 1
		SR_flug = 1

		icons = []
		membersArray = []

		for num in range(0,11):

			members = {}

			names = self.useGatcha.get_names(desc)
			if isinstance(names, str):
				if names.find("アルパカ"):
					rarity = self.useGatcha.get_rare("alpaca")
			else:
				rarity = self.useGatcha.get_rare("normal")

			if (desc.find('UR') > -1)and(rarity==1)and(random.randint(0,1)):
				rarity = 4
			if (desc.find('SR') > -1)and(rarity==1)and(random.randint(0,1)):
				rarity = 3

			if rarity > 1:
				dobu = 0
			elif (dobu == 1) and (num == 10):
			## SR確定
				rarity = 2
				dobu = 0


			series = 0
			if rarity > 1:
				print str(desc.rsplit(' ',1)[1].encode('utf-8'))
				series = str(desc.rsplit(' ',1)[1].encode('utf-8'))
				if not('編' in series):
					series = 0

			member_id = self.useSQL.rand_member(rarity,names,series)
			(member_rare, member_name, member_series, member_url, member_type, member_ss, member_sp, member_sc) = self.useSQL.get_member(member_id)
			(member_info, member_fullimgurl_0, member_fullimgurl_1) = self.useSQL.get_member_info(member_id)
			if (member_name != 'アルパカ' and member_rare == 'R') or (member_name == 'アルパカ' and member_rare == 'SR'):
				member_desc = member_rare + member_name
			else:
				member_desc = member_rare + member_name + "(" + member_series + ")"


			members["id"] = str(member_id)
			members["rarity"] = str(rarity)
			members["name"] = str(member_name)
			members["series"] = str(member_series)
			members["desc"] = str(member_desc)
			members["fullimgurl_0"] = str(member_fullimgurl_0)
			members["fullimgurl_1"] = str(member_fullimgurl_1)
			members["info"] = str(member_info)
			members["type"] = str(member_type)
			members["status_s"] = str(member_ss)
			members["status_p"] = str(member_sp)
			members["status_c"] = str(member_sc)

			filename = '/home/pi/sif/cap/manage_sif/icon'+str(num)+'.gif'
			command = "wget '"+str(member_url)+"' -O "+filename
#			check = commands.getoutput(command)

			icons.insert(num,filename+" "+str(rarity))

			if num < 11:
				membersArray.insert(num, members)



	#	self.useCV.create_gacha_image(icons)

		return membersArray
예제 #7
0
class smgatcha:
    """ Let's stare abstractedly at the User Streams ! """
    # インスタンス生成
    useTwitter = usetwitter.UseTwitter()
    useCV = usecv.UseCV()
    useBurp = useburp.UseBurp()
    useSQL = usesql.UseSQL()
    useGatcha = usegatcha.UseGatcha()
    point = points.Points()

    def dogatcha(self, desc):
        # Ubuntuの時は気づかなかったんだけど、Windowsで動作確認してたら
        # created_atはUTC(世界標準時)で返ってくるので日本時間にするために9時間プラスする。

        dobu = 1
        UR_flug = 1
        SR_flug = 1

        icons = []
        members = '['

        for num in range(0, 11):

            members = members + "{"

            names = self.useGatcha.get_names(desc)
            if isinstance(names, str):
                if names.find("アルパカ"):
                    rarity = self.useGatcha.get_rare("alpaca")
            else:
                rarity = self.useGatcha.get_rare("normal")

            if (desc.find('UR') > -1) and (rarity == 1) and (random.randint(
                    0, 1)):
                rarity = 4
            if (desc.find('SR') > -1) and (rarity == 1) and (random.randint(
                    0, 1)):
                rarity = 3

            if rarity > 1:
                dobu = 0
            elif (dobu == 1) and (num == 10):
                ## SR確定
                rarity = 2
                dobu = 0

            member_id = 30
            while member_id > 27 and member_id < 52:

                series = 0
                if rarity > 1:
                    print str(desc.rsplit(' ', 1)[1].encode('utf-8'))
                    series = str(desc.rsplit(' ', 1)[1].encode('utf-8'))
                    if not ('編' in series):
                        series = 0

                member_id = self.useSQL.rand_member(rarity, names, series)
            (member_name, member_url) = self.useSQL.get_member(member_id)
            (member_info, member_fullimgurl_0,
             member_fullimgurl_1) = self.useSQL.get_member_info(member_id)

            members = members + '"id":"' + str(member_id) + '",'
            members = members + '"name":"' + str(member_name) + '",'
            members = members + '"fullimgurl_0":"' + str(
                member_fullimgurl_0) + '",'
            members = members + '"fullimgurl_1":"' + str(
                member_fullimgurl_1) + '",'
            members = members + '"info":"' + member_info + '"'

            filename = '/home/pi/sif/cap/manage_sif/icon' + str(num) + '.gif'
            command = "wget '" + str(member_url) + "' -O " + filename
            check = commands.getoutput(command)

            #			print check
            icons.insert(num, filename + " " + str(rarity))

            if num == 10:
                members = members + "}"
            else:
                members = members + "},"

        members = members + "]"
        print "members:" + members

        self.useCV.create_gacha_image(icons)

        return members