Exemplo n.º 1
0
    def __init__(self, args):
        """
        Initializes a Circleguard instance.

        [SimpleNamespace or argparse.Namespace] args:
            A namespace-like object representing how and what to compare. An example may look like
            `Namespace(cache=False, local=False, map_id=None, number=50, threshold=20, user_id=None)`
        """

        # get all replays in path to check against. Load this per circleguard instance or users moving files around while the gui is open doesn't work.
        self.PATH_REPLAYS = [
            join(PATH_REPLAYS_STUB, f) for f in os.listdir(PATH_REPLAYS_STUB)
            if isfile(join(PATH_REPLAYS_STUB, f)) and f != ".DS_Store"
        ]

        self.cacher = Cacher(args.cache)
        self.args = args
        if (args.map_id):
            self.users_info = Loader.users_info(args.map_id, args.number)
        if (args.user_id and args.map_id):
            user_info = Loader.user_info(
                args.map_id, args.user_id
            )[args.
              user_id]  # should be guaranteed to only be a single mapping of user_id to a list
            self.replays_check = [
                OnlineReplay.from_map(self.cacher, args.map_id, args.user_id,
                                      user_info[0], user_info[1], user_info[2])
            ]
Exemplo n.º 2
0
 def __init__(self, reporter, waiter, outdir, useragent) -> None:
     super(Keiba, self).__init__()
     self.reporter: Reporter = reporter
     self.waiter = waiter
     self.outdir = outdir
     self.useragent = useragent
     self.cacher = Cacher(self.outdir)
     self.semaphore = Semaphore(2)
Exemplo n.º 3
0
 def enable_cache(self, host="localhost", port=27017, test=False):
     """
     @param host: the hostname of the server where mongodb is running
     @param port: port mongodb is listening on
     @param test: True if you want to work on a db separate than the main cache
     """
     self._cache_connection_host = host
     self._cache_connection_port = port
     self._cache_enabled = True
     self._cacher = Cacher(self._cache_connection_host,
                           self._cache_connection_port, test)
Exemplo n.º 4
0
    def __init__(self, wallet_config):
        self._errors = []
        self._config = {}
        self._cache = Cacher({
            'accounts': {},
            'transactions': {},
            'transactiondetails': {},
            'balances': {},
            'info': {},
        })

        if type(wallet_config) is dict:
            self._config = wallet_config
Exemplo n.º 5
0
    def __init__(self, accountDetails):
        self._errors = []
        self._account = {}
        self._hidden = False
        self._cache = Cacher({
            'transactions': {},
            'balances': {},
            'addressesbyaccount': {},
        })

        if type(accountDetails) is dict:
            self._account = accountDetails
            self._provider_id = accountDetails['provider_id']
Exemplo n.º 6
0
def setup():
    try:
        shutil.rmtree('webstashcache')
    except FileNotFoundError:
        pass

    try:
        os.remove('cacheMap.pkl')
    except FileNotFoundError:
        pass
    cacher = Cacher()
    link = 'https://news.ycombinator.com/news'
    return (cacher, link)
Exemplo n.º 7
0
    def __init__(self, args):
        """
        Initializes an Anticheat instance.

        [SimpleNamespace or argparse.Namespace] args:
            A namespace-like object representing how and what to compare. An example may look like
            `Namespace(cache=False, local=False, map_id=None, number=50, threshold=20, user_id=None)`
        """

        self.cacher = Cacher(args.cache)
        self.args = args
        if(args.map_id):
            self.users_info = Loader.users_info(args.map_id, args.number)
        if(args.user_id and args.map_id):
            user_info = Loader.user_info(args.map_id, args.user_id)
            self.replays_check = [OnlineReplay.from_map(self.cacher, args.map_id, args.user_id, user_info[args.user_id][0], user_info[args.user_id][1])]
Exemplo n.º 8
0
 def __init__(self,
              reporter: Reporter,
              waiter: Waiter,
              outdir: str,
              useragent: str = ''):
     super(WearCollector, self).__init__()
     self.reporter: Reporter = reporter
     self.waiter = waiter
     self.outdir = outdir
     self.useragent = useragent
     self.cacher = Cacher(self.outdir)
     # 非同期処理の同時接続数制御
     self.semaphore = Semaphore(2)
     # ファイルダウンローダ
     self.downloader = Downloader(self.waiter, self.semaphore,
                                  self.reporter)
Exemplo n.º 9
0
    def __init__(self, transactionDetails):
        self._transaction = {}
        self._cache = Cacher({
            'details': {},
        })

        if type(transactionDetails) is dict:
            self._transaction = transactionDetails

            self['timereceived_pretty'] = misc.twitterizeDate(
                self.get('timereceived', 'never'))
            self['time_pretty'] = misc.twitterizeDate(self.get(
                'time', 'never'))
            self['timereceived_human'] = datetime.datetime.fromtimestamp(
                self.get('timereceived', 0))
            self['time_human'] = datetime.datetime.fromtimestamp(
                self.get('time', 0))
            self['blocktime_human'] = datetime.datetime.fromtimestamp(
                self.get('blocktime', 0))
            self['blocktime_pretty'] = misc.twitterizeDate(
                self.get('blocktime', 'never'))
            self['currency_symbol'] = misc.getCurrencySymbol(
                connector, self['currency'])

            if self.get('category', False) in ['receive', 'send']:
                if self['confirmations'] <= MainConfig['globals'][
                        'confirmation_limit']:
                    self['status_icon'] = 'glyphicon-time'
                    self['status_color'] = '#AAA'
                    self['tooltip'] = self['confirmations']
                else:
                    self['status_icon'] = 'glyphicon-ok-circle'
                    self['status_color'] = '#1C9E3F'
                    self['tooltip'] = self['confirmations']

            accountObject = self['wallet'].getAccountByName(self['account'])
            self['account'] = accountObject

            if self['category'] == 'receive':
                self['icon'] = 'glyphicon-circle-arrow-down'
            elif self['category'] == 'send':
                self['icon'] = 'glyphicon-circle-arrow-up'
            elif self['category'] == 'move':
                self['icon'] = 'glyphicon-circle-arrow-right'
                self['otheraccount'] = self['wallet'].getAccountByName(
                    self['otheraccount'])
Exemplo n.º 10
0
#
# Read and analyze output from ptrace-sampler
#

import sys
import os
import time
import subprocess
import select
import re
import resource

from lib_finder import LibFinder
from cacher import Cacher

cache = Cacher()


class Mappings:
    def __init__(self):
        self.origLines = []
        self.mappings = []

    def parseLine(self, line):
        self.origLines.append(line)

        # b74b3000-b760f000 r-xp 00000000 09:00 9593032    /lib/tls/i686/cmov/libc-2.9.so
        #(addrs, perms, offset, dev, inode, path) = line.split()
        parts = line.split()

        addrs = parts[0].split('-')
Exemplo n.º 11
0
 def __init__(self, api, search_radius=1000, auto_next=False):
     self.api = api
     self.search_radius = search_radius
     self.auto_next = auto_next
     self.cache = Cacher('cache2.txt')
Exemplo n.º 12
0
 def __init__(self, api):
     self.api = api
     self.cache = Cacher()
Exemplo n.º 13
0
 def __init__(self, getterType='urlopen', waitTimeBeforeScraping=0):
     self.cacher = Cacher()
     self.config = Config()
     self.getter = Getter(getterType,
                          waitTimeBeforeScraping=waitTimeBeforeScraping)
Exemplo n.º 14
0
 def __init__(self, api):
     self.api = api
     self.cache = Cacher('cache2.txt')