示例#1
0
文件: window.py 项目: puzzlet/cgkit
    def __init__(self,
                 parent=None,
                 id=-1,
                 title='Title',
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.DEFAULT_FRAME_STYLE | wx.CLIP_CHILDREN):
        """Create a Frame instance.
        """

        # Create the actual window (a wx Frame)
        self._wx = wx.Frame(parent, id, title, pos, size, style)

        self._keys = keys.Keys()
        self._keys.attach(self)

        # Set up the wx main menu bar
        self._menu_id_manager = idmanager.IDManager(10)
        menubar = wx.MenuBar()
        self._wx.SetMenuBar(menubar)
        self._menu = None

        self.CreateStatusBar()

        wx.EVT_LEFT_DOWN(self, self.onLeftDown)
        wx.EVT_LEFT_UP(self, self.onLeftUp)
        wx.EVT_MIDDLE_DOWN(self, self.onMiddleDown)
        wx.EVT_MIDDLE_UP(self, self.onMiddleUp)
        wx.EVT_RIGHT_DOWN(self, self.onRightDown)
        wx.EVT_RIGHT_UP(self, self.onRightUp)
	def __init__( self, dataDir, fmt = "mp3" ):
		self.dataDir = dataDir
		self.rid = "%07i" %( time.time() % 10000000 )
		self.keys = keys.Keys( self.dataDir, PROTOCOL_VERSION )
		if not self.keys.loadKeys():
			raise PandoraError("Unable to load keys")
		self.curFormat = fmt
示例#3
0
文件: commands.py 项目: royces9/sqlmp
    def __init__(self, ui):
        self.ui = ui
        self.textwin = self.ui.textwin

        #typed commands
        self.commands = {
            'add': self.add,
            'delpl': self.delpl,
            'export': self.export,
            'export-all': self.export_all,
            'find': self.find,
            'newpl': self.newpl,
            'playmode': self.playmode,
            'renamepl': self.renamepl,
            'sort': self.sort,
            'update': self.update,
            'update-single': self.update_single
        }

        self.err = Error_msg(self.ui, 2, self.ui.frame_time,
                             self.textwin.print_blank, (1, ))
        self.find_list = None

        #handles input for typed commands
        self.keys = keys.Keys()
        #flag to decide if command is getting entered
        self.inp = False

        self.command_event = threading.Event()
        self.command_event.set()
示例#4
0
def perform_actions():
    key = keys.Keys()
    key.directKey("w")
    utils.press_key("x", key)
    while INDEX < len(points):
        utils.run_bot(CURRENT_POSITION, CURRENT_POINT, key)
        perform_additional_actions(game_data=CURRENT_POSITION, key=key)
        time.sleep(0.016)
    key.directKey("w", key.key_release)
 def __init__(self):
     self.vnfid_timestamps = {}
     #rl_module = module()
     self.keys = keys.Keys()
     self.scale_up_message = {
         self.keys.flavor: "single",
         self.keys.volume: "small",
         self.keys.ns_id: "3ef4dfc2-ac73-4171-938f-4fddcce3fec3",
         self.keys.vnf_id: "34ae306c-2fba-45ef-97ed-bbf77ca5528e",
         self.keys.vnf_index: "2",
         self.keys.sampling_time: 5,
         self.keys.scale_decision: "scale_up"
     }
     self.start()
示例#6
0
def main(try_count):
    # Initialize address generator
    k = keys.Keys()
    conn = sqlite3.connect('address.db')
    batch_size = 60
    n = 0

    while n < try_count:
        print('\nAttempt #{0} (Checked: {1})'.format(n + 1,
                                                     batch_size * (n + 1)))
        try:
            address_search(k, conn, batch_size)
        except Exception as e:
            print('Encountered error: {}'.format(e))
        n += 1
示例#7
0
    def __init__(self, charts, start_date="2018-10-13",
                 stop_date='1958-01-01', backtrack=False,
                 es=False, max_records=20, max_threads=3):
        """

        :param charts:
        :param start_date:
        :param stop_date:
        :param backtrack:
        :param es:
        :param max_records:
        """
        self.start_date = start_date
        self.stop_date = stop_date
        self.backtrack = backtrack
        self.use_es = es
        self.charts = charts
        self.max_records = max_records
        self.max_threads = max_threads

        self.chart_partition = []
        for thread in range(self.max_threads):
            self.chart_partition.append([])
        for num in range(len(self.charts)):
            self.chart_partition[num%self.max_threads].\
                append(self.charts[num])
        print("Chart Partitions", self.chart_partition)

        api_keys = keys.Keys()
        self.AZ = azlyrics.AZLyricsScraper()
        self.GS = genius.GeniusScraper(
            token=api_keys.genius_token
        )
        self.SS = spotify.SpotifyScraper(
            client_id=api_keys.spotify_client_id,
            client_secret=api_keys.spotify_client_secret
        )
        self.BB = billboards.BillboardScraper()
        self.WS = wikia.WikiaScraper()
        self.Proc = processing.LyricAnalyst()
        if self.use_es:
            self.ES = elasticsearchdb.ElasticSearch("song_data")
        self.records_processed = 0
示例#8
0
 def __init__(self, base_url, sdm_ip, sdm_port):
     self.monitoringtime = datetime.datetime.now()
     self.TAG = "VnfManager"
     self.load_balancer_docker_id = "haproxy"  # it's the docker name of the load balancer
     self.haproxy_cfg_name = "haproxy.cfg"  #its the configuration filename
     self.sdm_port = sdm_port  # port of the scale decision module
     self.sdm_ip = sdm_ip  # port of the scale decision module ip
     self.vnf_scale_module = VnfScaleModule()
     self.cadvisor_url = base_url.replace(
         "https", "http") + ":8080/api/v1.3/subcontainers/docker"
     self.osm_helper = OsmHelper(base_url + ":9999/osm/")
     self.keys = keys.Keys()
     self.vnf_message = {}
     self.custom_print("init")
     self.custom_print("load balancer docker id: {}, cfg name: {}".format(
         self.load_balancer_docker_id, self.haproxy_cfg_name))
     asyncio.ensure_future(self.start(sdm_ip, base_url))  #main loop
     pending = asyncio.Task.all_tasks()
     loop = asyncio.get_event_loop()
     loop.run_until_complete(asyncio.gather(*pending))
     loop.run_forever()
示例#9
0
def custom_vision_endpoint(user_image_url):

    payload = {
        #  "Url": user_image_url
        "Url": user_image_url
    }
    headers = {
        "Content-Type": "application/json",
        "Prediction-Key": "66aaad81eed9481bba65df01dfe09420"
    }

    url = "https://southcentralus.api.cognitive.microsoft.com/customvision/v1.0/Prediction/91f2d2f7-5c8d-4eb3-a741-a9c75ab6fc41/url"
    response = requests.post(url, data=json.dumps(payload), headers=headers)
    response = response.json()
    # if custom model has high probability rate, return recommendations
    if response['Predictions'][0]['Probability'] > 0.75:
        val = response['Predictions'][0]['Tag']
        return json.dumps(semantics.get_recommendations(val))
    # call clarifai api otherwise
    else:
        k = keys.Keys()
        app = ClarifaiApp(api_key=k.get_clarifai_key())
        # Use apparel model
        model = app.models.get('apparel')
        image = ClImage(url=user_image_url)
        result = model.predict([image])
        concepts = result['outputs'][0]['data']['concepts']
        # check for high confidence
        if concepts[0]['value'] >= 0.9:
            val = concepts[0]['name']
            return json.dumps(semantics.get_recommendations(val))

        # otherwise provide the user with choice
        output = []
        for i in range(3):
            output.append(semantics.get_recommendations(concepts[i]['name']))
        return json.dumps(output)


#custom_vision_endpoint("http://viliflik.files.wordpress.com/2010/10/glasses-best.jpg")
示例#10
0
def get_recommendations(name, brand=None):
    k = keys.Keys()

    #    categories = Categories(
    #       api_key = k.get_semantics_api_key(),
    #      api_secret = k.get_semantics_secret_key()
    #  )

    products = Products(api_key=k.get_semantics_api_key(),
                        api_secret=k.get_semantics_secret_key())

    products.products_field("search", name)
    if brand != None:
        products.products_field("brand", brand)
    products.products_field("variation_includeall", 0)
    products.products_field("limit", 10)
    results = products.get()

    output = []

    for r in results["results"]:
        data = {}
        try:
            data['image'] = r["images"][0]
        except:
            pass
        data['url'] = r['sitedetails'][0]["url"]

        try:
            data['price'] = r['sitedetails'][0]["latestoffers"][0]["price"]
        except:
            pass
        try:
            data['brand'] = r['brand']
        except:
            pass
        data['title'] = r['name']
        data['status'] = True
        output.append(data)
    return {"results": output}
示例#11
0
# coding: utf-8
# # Object Detection Demo
# License: Apache License 2.0 (https://github.com/tensorflow/models/blob/master/LICENSE)
# source: https://github.com/tensorflow/models
import numpy as np
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile
import keys as k
import time

keys = k.Keys({})

X1 = 0
Y1 = 60
X2 = 1600
Y2 = 1200

from collections import defaultdict
from io import StringIO
from matplotlib import pyplot as plt
from PIL import Image
from grabscreen import grab_screen
import cv2

# This is needed since the notebook is stored in the object_detection folder.
sys.path.append("..")
示例#12
0
import cv2
import time
import random
import imutils
import keyboard
import keys as k
import numpy as np
from PIL import ImageGrab
import pydirectinput as pdi
from PIL import Image, ImageOps

os.chdir('dataset')

np.set_printoptions(threshold=sys.maxsize)

keys = k.Keys()
say = 0

global soltara
soltara = 127
global sagtara
sagtara = 128
global tarayukseklik
tarayukseklik = 70


def tara():
    '''
    global sagtara
    sagtara = 128
    global soltara
示例#13
0
import numpy as np
import cv2
import math, time

import framegrabber, getkeys, keys

keyboard = keys.Keys()


def preview_img(screen):

    w = "nfs-minimap"
    cv2.namedWindow(w)
    cv2.moveWindow(w, 4000, 800)
    cv2.imshow(w, screen)
    cv2.waitKey(1)


def process_minimap(screen):

    half_image = int(screen.shape[0] / 2)
    distance = 30

    yellowLowerBoundary = np.array([20, 100, 100])
    yellowUpperBoundary = np.array([40, 255, 255])

    mask = cv2.cvtColor(screen, cv2.COLOR_BGR2HSV)
    mask = cv2.inRange(mask, yellowLowerBoundary, yellowUpperBoundary)
    mask = cv2.dilate(mask, np.ones((2, 2), np.uint8))
    mask = cv2.erode(mask, np.ones((5, 5), np.uint8))
示例#14
0
 def generate_address():
     k = keys.Keys()
     return k.generate()
示例#15
0
import time
import json
import pymem
import keys
import keyboard
import mouse
from pymem import Pymem
from math import acos, pi, sin, sqrt, isclose

"""попытка сделать идеальный лифт"""

if __name__ == "__main__":
    pm = Pymem("XR_3DA.exe")
    keys = keys.Keys()
    module_offset = None
    for i in list(pm.list_modules()):
        if(i.name == "xrGame.dll"):
            module_offset = i.lpBaseOfDll
    plahka = False
    points = None
    with open("dataclean", mode="r") as file:
        points = json.loads(file.read())
    index = 0
    for i in range(2):
        print(i)
        time.sleep(1)
    keys.directKey("lctrl")
    time.sleep(0.016)
    keys.directKey("lshift")
    time.sleep(0.016)
示例#16
0
import requests
import time
from ObserverPattern.vnf_observer_pattern import VnfCpuSubject as CpuSubject
import collections
import asyncio, maya, math
import keys as keys
from utils.colors import bcolors

ki = keys.Keys()
DockerInstance = collections.namedtuple(
    'DockerInstance', (ki.docker_name, ki.docker_id, ki.vnf_id, ki.ns_id,
                       ki.vnf_index, ki.sampling_time, ki.volume, ki.flavor))


#TODO hacer refactor con las constantes en unas sola clase.
#TODO hacer una maquina de estado
class DockerSupervisor(CpuSubject):
    _observers = None
    _state = None

    def __init__(self, cadvisor_url, ns_id, vnf_id, index, sampling_time,
                 volume, flavor):
        docker_name = self.get_docker_name(ns_id, vnf_id, flavor, volume)
        #docker_name = "py_serv"
        self.cadvisor_url = cadvisor_url
        self.cadvisor_url_cpu = cadvisor_url.replace(
            "v1.3/subcontainers/docker", "v1.0/containers/docker")
        self.nano_secs = math.pow(10, 9)
        self.cpu_load = None
        self.rx_usage = None
        self.tx_usage = None
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile

from collections import defaultdict
from io import StringIO

## mss is supposed to be v'fast. I have no complaints with it either.
from mss import mss
import cv2
import keys as k
import time
keys = k.Keys()  ## HELPS WITH MOUSE INPUT ETC. THIS IS A DIRECT INPUT

# This is needed since the notebook is stored in the object_detection folder.
sys.path.append("..")

# ## Object detection imports
# Here are the imports from the object detection module.

from utils import label_map_util

from utils import visualization_utils as vis_util

# What model to download.
MODEL_NAME = 'ssd_mobilenet_v1_coco_11_06_2017'
MODEL_FILE = MODEL_NAME + '.tar.gz'
DOWNLOAD_BASE = 'http://download.tensorflow.org/models/object_detection/'