コード例 #1
0
ファイル: game.py プロジェクト: FarmerB05/ProjectNegative42
class Game:
    def __init__(self):

        # Settings
        self.settings = Settings()
        self.settings.load()

        self.screen = window(self.settings)
        self.running = True
        self.clock = pygame.time.Clock()
        self.fps = self.settings.fps
        self.dt = self.clock.tick(self.fps) / 1000

        self.last_screen = [0, 0]
        self.fps_label = Text(self.screen,
                              int(self.clock.get_fps()), [0, 0, 50, 50],
                              font_size=35)

    def video_event(self, event):
        if event.type == pygame.VIDEORESIZE:
            if not self.settings.fullscreen:
                self.last_screen = [
                    self.screen.get_width(),
                    self.screen.get_height()
                ]
                self.screen = pygame.display.set_mode((event.w, event.h),
                                                      pygame.RESIZABLE)
            return True
        return False

    def update(self):
        self.fps_label = Text(self.screen,
                              int(self.clock.get_fps()), [0, 0, 50, 50],
                              font_size=35)

    def draw(self):
        self.screen.fill((0, 0, 0))
        self.fps_label.draw()
コード例 #2
0
ファイル: cache.py プロジェクト: pombredanne/cve-new
 def __init__(self):
     st = Settings()
     self.settings = st.load()
     self.host = self.settings['redis_host']
     self.port = self.settings['redis_port']
     self.db = redis.StrictRedis(host=self.host,
                                 port=self.port,
                                 charset="utf-8",
                                 decode_responses=True)
     self.collection_tasks = self.settings[
         'redis_collection_name'] + ':' + self.settings[
             'redis_collection_tasks']
     self.collection_log = self.settings[
         'redis_collection_name'] + ':' + self.settings[
             'redis_collection_log']
     self.collection_cve = self.settings[
         'redis_collection_name'] + ':' + self.settings[
             'redis_collection_cve']
     self.collection_cpe = self.settings[
         'redis_collection_name'] + ':' + self.settings[
             'redis_collection_cpe']
     self.collection_cwe = self.settings[
         'redis_collection_name'] + ':' + self.settings[
             'redis_collection_cwe']
     self.collection_cpeother = self.settings[
         'redis_collection_name'] + ':' + self.settings[
             'redis_collection_cpeother']
     self.collection_whitelist = self.settings[
         'redis_collection_name'] + ':' + self.settings[
             'redis_collection_whitelist']
     self.collection_blacklist = self.settings[
         'redis_collection_name'] + ':' + self.settings[
             'redis_collection_blacklist']
     self.collection_info = self.settings[
         'redis_collection_name'] + ':' + self.settings[
             'redis_collection_info']
     self.collection_ranking = self.settings[
         'redis_collection_name'] + ':' + self.settings[
             'redis_collection_ranking']
     self.collection_via4 = self.settings[
         'redis_collection_name'] + ':' + self.settings[
             'redis_collection_via4']
     self.collection_capec = self.settings[
         'redis_collection_name'] + ':' + self.settings[
             'redis_collection_capec']
     self.complete_flag = self.settings['redis_complete_flag']
コード例 #3
0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import boto3
from settings.settings import Settings
settings = Settings.load()

class LambdaInterface(object):

  def __init__(self, func_name):
    self.client = boto3.client('lambda')
    self.func_name = func_name

  def readZipFile(self, zip_file, encode_base64=True):
    return None

  def createFunction(self, zip_file, timeout=10, memory_size=128):
    """Create a lambda function"""
    try:
      response = self.client.create_function(
          FunctionName = self.func_name,
コード例 #4
0
class Entity:
    def __init__(self, screen, rect, health=100, name=None, save_entity=False):

        # Load settings
        self.settings = Settings()
        self.settings.load()

        self.screen = screen
        self.rect = rect

        # Save
        self.name = name
        self.save_entity = save_entity
        self.file_path = 'data/data.json'

        # Just incase
        if name is None and self.save_entity:
            print('Saved was set to true, but no name was passed.')
            self.save_entity = False

        # Health
        self.max_health = health
        self.health = self.max_health
        self.health_rect = [
            int(self.rect[0] + self.rect[2] / 2 - int(self.rect[2] * 1.3) / 2),
            int(self.rect[1] - int(self.rect[3] / 8) * 3),
            int(self.rect[2] * 1.3),
            int(self.rect[3] / 8)
        ]
        self.health_color = (255, 0, 0)

        # Loadout
        # These if not none will need to be passed into the control script for entity
        self.weapon = None
        self.helmet = None
        self.chestplate = None
        self.boots = None

    def health_bar(self):
        self.health_rect = [
            int(self.rect[0] + self.rect[2] / 2 - int(self.rect[2] * 1.3) / 2),
            int(self.rect[1] - int(self.rect[3] / 8) * 3),
            int(self.rect[2] * 1.3),
            int(self.rect[3] / 8)
        ]
        pygame.draw.rect(self.screen, (0, 0, 0), self.health_rect, 1)

        if self.health <= self.max_health * 0.25:
            self.health_color = (255, 0, 0)
        elif self.health <= self.max_health * 0.60:
            self.health_color = (255, 255, 0)
        else:
            self.health_color = (51, 255, 51)

        pygame.draw.rect(
            self.screen, self.health_color,
            (self.health_rect[0], self.health_rect[1],
             (self.health /
              (self.max_health / self.health_rect[2])), self.health_rect[3]))

    def update(self):
        pass

    def draw(self):
        self.health_bar()
        pygame.draw.rect(self.screen, (255, 0, 255), self.rect)

    """
コード例 #5
0
import os
import sys

runPath = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(runPath, ".."))

import urllib.request as req
import zipfile
from io import BytesIO
import gzip
import bz2
from settings.settings import Settings
st = Settings()
cfg = st.load()


def getFile(getfile, unpack=True):
    if cfg['http_proxy']:
        proxy = req.ProxyHandler({
            'http': cfg['http_proxy'],
            'https': cfg['http_proxy']
        })
        auth = req.HTTPBasicAuthHandler()
        opener = req.build_opener(proxy, auth, req.HTTPHandler)
        req.install_opener(opener)
    response = req.urlopen(getfile)
    data = response
    if unpack:
        if 'gzip' in response.info().get('Content-Type'):
            buf = BytesIO(response.read())
            data = gzip.GzipFile(fileobj=buf)