def test_add_outcome(self):
     wheel = spinner.Spinner(BuilderMock())
     for _ in xrange(spinner.Spinner.SPINNER_SIZE * 10):
         outcomes = wheel.spin()
         if outcomes:
             self.assertSetEqual(outcomes,
                                 {"outcome0", "outcome1", "outcome2"})
Example #2
0
    def __init__(self, args):
        self.currencies = config.Configuration.config["currencies"]
        self.currency_conversion = config.Configuration.config[
            "currency_conversion"]
        self.api_histo_hour_limit = config.Configuration.config[
            "api_histo_hour_limit"]
        self.api_histo_hour_url = config.Configuration.config[
            "api_histo_hour_url"]
        self.db_config = config.Configuration.config["database"]

        self.save_to_file = config.Configuration.config["save_to_file"]

        self.database = database.Database(self.db_config["host"],
                                          self.db_config["port"],
                                          self.db_config["database"],
                                          self.db_config["user"],
                                          self.db_config["password"])

        self.unix_socket = config.Configuration.config["unix_socket"]
        self.spinner = spinner.Spinner()
        self.args = args
        self.since = 0
        self.step = 0
        self.hours_needed = 0
        self.start_time = time.time()
Example #3
0
    def onModuleLoad(self):
        self.tabs = TabPanel()
        tab_overview = TabContainer()
        self.tabs.add(tab_overview, 'Overview')

        self.tab_events = TabRaphaelContainer()
        self.tab_events.set_headline('Events Example')
        self.tab_events.set_raphael(events.Events(width=600, height=300))
        self.tab_events.set_status('Execute events on Raphael Elemnts')
        self.tabs.add(self.tab_events, 'Events')

        self.tab_graffle = TabRaphaelContainer()
        self.tab_graffle.set_headline(
            'This is a simple example of the Raphael Graffle')
        self.tab_graffle.set_raphael(graffle.Graffle(width=600, height=300))
        self.tabs.add(self.tab_graffle, 'Graffle')

        self.tab_spinner = TabRaphaelContainer()
        self.tab_spinner.set_headline('This Raphael Spinner Example')
        self.tab_spinner.set_raphael(spinner.Spinner(width=600, height=300))
        self.tabs.add(self.tab_spinner, 'Spinner')

        self.tabs.selectTab(0)
        self.tabs.setWidth("100%")
        self.tabs.setHeight("100%")
        RootPanel().add(self.tabs)
Example #4
0
 def __init__(self, dev_path):
     #init serial to dev path
     self.spinner = spinner.Spinner()
     self._sensor_data_lock = threading.Lock()
     self._serial_lock = threading.Lock()
     self._serial_device = serial.Serial(port=dev_path, timeout=SERIAL_TIMEOUT)
     self._sensor_data = FloatDict()
 def builder(
     self, outcome_value
 ):  #makes an outcome out of the representative string of the outcome, checks for validity on my unfinished generator; is there any way not to recreate a generator every time?
     """
     :param outcome_value:
     :type outcome_value: str
     :return:
     """
     t_outcome = Outcome(outcome_value,
                         35 / (len(outcome_value.split("-"))))
     spin = spinner.Spinner()  # less cool
     if t_outcome in spin._bin():
         return t_outcome
     return Outcome("10", 35)
Example #6
0
def cli(debug, verbose):
    click.clear()
    click.secho("RPA Tomorrow - managing tasks from natural text", fg="green", bold=True)

    spin = spinner.Spinner()
    load_prerequisites(spin, debug, verbose)
    n = load_selector(spin)

    click.secho("\nType any task(s) and the robot will start working on it", bold=True)
    click.secho("(or type 'help' to display all options):", bold=True)
    suffix = click.style(">>> ", bold=True, fg="bright_cyan")
    try:
        while True:
            txt = click.prompt("", prompt_suffix=suffix).strip()

            if txt == "":
                continue
            else:
                txt_arr = txt.split(" ")
                commands.commands(txt_arr, n)
    except Exception:
        click.secho("\nGood bye!", fg="green", bold=True)
        click.clear()
# Download data in canonical form
df_all_variables = pd.DataFrame()
for v in variable_ids:
    response = get(
        f'{datamart_api_url}/datasets/{dataset_meta["dataset_id"]}/variables/{v}'
    )
    df = pd.read_csv(StringIO(response.text))
    if df_all_variables.shape[0] == 0:
        df_all_variables = df
    else:
        df_all_variables = df_all_variables.append(df)
df_all_variables = df_all_variables.reset_index().drop(columns=['index'])

df_all_variables.reset_index().to_csv('csv/tmp.csv')

# Upload to NYU
#login to wm auctus
api_url = f'https://{username_nyu}:{password_nyu}@{url_nyu}'
url_upload = api_url + 'upload'
url_meta = api_url + 'metadata/'

# Upload to datamar
dataset = open('csv/tmp.csv', 'rb')
dataset_id = nyu.upload_data(url_upload, dataset, dataset_meta["name"],
                             dataset_meta["description"])

#...wait for good response
print("Registering your dataset, this may take awhile...")
with sp.Spinner():
    nyu.get_status(url_meta, dataset_id)
Example #8
0
 def showSpinner(self, text):
     self._infoSpinner = spinner.Spinner(self._textFrame)
     self._infoSpinner.show(indicators=False, message=text)
    print("Input Image File:= {0}".format(in_file))
    print("Output file:= {0}".format(out_file))
    print("Tile Images Directory:= {0}".format(tiles_dir))
    print("Output Directory:= {0}".format(output_dir))

    if (len(num_tiles) > 1):
        num_tiles_tot = num_tiles[0] * num_tiles[1]
        print("Number of Tiles:= {0}".format(num_tiles_tot))
    else:
        print("Number of Tiles:= {0}".format(*num_tiles))

    print()
    
    sys.stdout.write("Program Running: ")
    spinner = spinner.Spinner()
    spinner.start()

    temp_tile_path = Path(os.path.abspath(str(tiles_dir)))

    files = [str(temp_tile_path / f) for f in listdir(str(temp_tile_path)) if isfile(str(temp_tile_path / Path(f)))]

    image_mos = image_mosiac(target_image_file, files, num_tiles, mode, transform)

    image = image_mos.return_image()
    image.show()

    with open(str(out_file), 'w') as f:
        image.save(f)
    
    spinner.stop()
import spinner
import outcome
import bin_stuff
banana = spinner.Spinner()
print banana.spin()
Example #11
0
# CLI Tool for downloading Full Movies on YouTube via Reddit.
# See README.md for setup instructions
# V0.05 Adding in downloading framework

from __future__ import unicode_literals
import youtube_dl
import praw  # for interacting w/Reddit
import spinner  # bring in the loading animation

SPIN = spinner.Spinner()  # create a spinner from spinner.py
DIV = "\n" + ("~*" * 20)  # This is just a Divider for printing
# Error msg for no guide comment
GUIDE_ERROR = "Sorry, there is no info available for this movie."
AFFIRMATIVE = ['y', 'Y']
NEGATIVE = ['n', 'N']

reddit = praw.Reddit('movie_grabber', user_agent='movie_grabber user agent')
subreddit = reddit.subreddit('fullmoviesonyoutube')


def get_submissions(subreddit, subs_viewed):
    """Grabs the 10 newest submissions"""
    print("Grabbing 10 movies...")
    SPIN.start()  # animate spinner while running rest of method
    submissions = []  # This will be the list of 10 links, each stored as dict
    # Iterate through 10 newest submissions
    for submission in subreddit.new(limit=10):
        guide = get_guide_comment(submission)  # find MovieGuide comment
        if guide is None:  # if MovieGuide comment cannot be found, load error message
            guide = GUIDE_ERROR
        subdata = dict(  # Store submission data as dictionary of title:{necessary data}
Example #12
0
from __future__ import unicode_literals
import youtube_dl
import spinner

spin = spinner.Spinner()


class MyLogger(object):
    def debug(self, msg):
        pass

    def warning(self, msg):
        print(msg)

    def error(self, msg):
        print(msg)


def my_hook(d):
    if d['status'] == 'downloading':
        spin.start()
    if d['status'] == 'finished':
        spin.stop()
        print('Done downloading, now converting ...')


ydl_opts = {
    'format': 'bestaudio/best',
    'postprocessors': [{
        'key': 'FFmpegExtractAudio',
        'preferredcodec': 'mp3',
Example #13
0
    },
    {
        "channel": 2,
        "side": 1,
        "direction": -1
    },
    {
        "channel": 3,
        "side": 1,
        "direction": 1
    },
]
dt = drivetrain.DriveTrain(m, dt_motors)

spinner_servo = {"channel": 4, "direction": 1}
spinner = spinner.Spinner(m, spinner_servo)

tilter_servo = {"channel": 5, "direction": -1}
tilter = tilter.Tilter(m, tilter_servo)

releaser_servos = {"test1": {"channel": 6}, "test2": {"channel": 7}}
releaser = releaser.Releaser(m, releaser_servos)

j = xbox.Joystick()

# Wrapping the robot loop in a try/finally structure makes sure that the robot stops
# moving if your code errors out or the robot loop completes.
try:
    enabled = True
    print "Robot loop started"
    while enabled:
Example #14
0
    for hero_name in tqdm.tqdm(heroes_names):
        response = requests.get(API_URL + TOKEN + '/search/' + hero_name,
                                headers=USER_AGENT)
        data = response.json()
        if data['response'] != 'success':
            continue
        for hero in data['results']:
            # strict check if name is exact what we are looking for
            if hero['name'] != hero_name:
                continue
            # let's normalize characteristics and summarize the score
            hero['score'] = 0
            for char in characteristics:
                try:
                    hero['score'] += int(hero['powerstats'][char])
                except ValueError:
                    pass
            result.append(hero)
    return result


with spinner.Spinner():
    heroes = get_score_by_characteristic(API_URL + TOKEN + '/search/',
                                         heroes_names, characteristics)

if len(heroes) > 0:
    heroes.sort(key=lambda x: int(x['score']), reverse=True)
    # print(*heroes, sep='\n')
    print(
        f'SuperHero is: {heroes[0]["name"]} with score: {heroes[0]["score"]}')
Example #15
0
    def __init__(self, game, num):
        self.game = game
        self.num = num
        self.tm = 0
        self.tmu = 0
        self.tmv = num * 16
        
        self.state = STATE_INTRO
        if self.num <= 0:
            self.state = STATE_DEMO
        elif self.num == MAX_STAGE_NUM + 1:
            self.tm = 1
            self.tmu = 0
            self.tmv = 0
            self.state = STATE_GAME_COMPLETE
        
        self.solid_rects = [
            [0, 0, 160, 16], # [x, y, w, h]
            [0, 16, 8, 128],
            [152, 16, 8, 128],
            [0, 136, 160, 8]
        ]
        
        self.slopes = [] # [x, y]
        self.pockets = [] # [x, y, w, h]
        self.lights = [] # Light objects
        self.spinners = [] # Spinner objects
        
        self.en_spawn_locs_topleft = [] # [[x,y],[x,y],[x,y]...]
        self.en_spawn_locs_topright = [] # [[x,y],[x,y],[x,y]...]
        self.en_spawn_locs_bottomleft = [] # [[x,y],[x,y],[x,y]...]
        self.en_spawn_locs_bottomright = [] # [[x,y],[x,y],[x,y]...]
        
        if self.state != STATE_GAME_COMPLETE:
            for yc in range(HEIGHT_TILES):
                y = self.tmv + yc
                for xc in range(WIDTH_TILES):
                    x = self.tmu + xc
                    tile = pyxel.tilemap(self.tm).get(x, y)
                    if tile == POST_TILE:
                        self.solid_rects.append([xc*8 + 8, yc*8 + 16, 8, 8])
                    elif tile in SLOPE_TILES:
                        self.slopes.append([xc*8 + 8, yc*8 + 16])
                    elif tile == LIGHT_TILE:
                        self.lights.append(light.Light(xc*8 + 8, yc*8 + 16))
                        
                    if tile == POCKET_TILE_NW:
                        if x < self.tmu + WIDTH_TILES-1 and y < self.tmv + HEIGHT_TILES-1:
                            if pyxel.tilemap(self.tm).get(x+1, y) == POCKET_TILE_NE and\
                                pyxel.tilemap(self.tm).get(x+1, y+1) == POCKET_TILE_SE and\
                                pyxel.tilemap(self.tm).get(x, y+1) == POCKET_TILE_SW:
                                    self.pockets.append([xc*8 + 8, yc*8 + 16, 16, 16])
                                    
                    if tile != POST_TILE and \
                        xc > 0 and \
                        xc < WIDTH_TILES-1 and \
                        yc > 0 and \
                        yc < HEIGHT_TILES-1 and \
                        (xc < 5 or xc > WIDTH_TILES-6) and \
                        (yc < 5 or yc > HEIGHT_TILES-6):
                        
                        loc = [xc*8 + 8 + 4, yc*8 + 16 + 4]
                        
                        if xc < 9:
                            if yc < 7:
                                self.en_spawn_locs_topleft.append(loc)
                            else:
                                self.en_spawn_locs_bottomleft.append(loc)
                        else:
                            if yc < 7:
                                self.en_spawn_locs_topright.append(loc)
                            else:
                                self.en_spawn_locs_bottomright.append(loc)

            #print(self.pockets)
            num_spinners = 0
            stage_diff_name = stagedata.STAGE_DIFFICULTY[self.num]
            for i in range(len(spinner.TYPES)):
                en_qty = stagedata.ENEMIES[stage_diff_name][stagedata.SPINNER_KEY][i]
                for sq in range(en_qty):
                    loc = self.get_random_spawn_loc(-1)
                    self.spinners.append(spinner.Spinner(loc[0], loc[1], i))
        
        self.player = player.Player(75,75)#(12, 20)
        if self.state == STATE_GAME_COMPLETE:
            self.player.state = player.STATE_GAME_COMPLETE
            audio.play_music(audio.MUS_IN_GAME, True)
        else:
            if self.state != STATE_DEMO:
                audio.play_music(audio.MUS_START, False)
        
        self.pause_menu = PauseMenu(self)
        
        self.stage_over_ticks = 0
        
        self.next_stage_flash_num = 0
Example #16
0
    pass


# Create a signal handler that raises a timeout event
# when the capture duration is reached


def handler(signum, frame):
    if True:
        print 'Capture Complete', signum
        print

        raise myTimeout()


if __name__ == '__main__':
    capturedDuration = 1 * 5  # seconds

    signal.signal(signal.SIGALRM, handler)
    signal.alarm(capturedDuration)

    sp = spinner.Spinner()

    try:
        while True:
            sp.Spin()
            sleep(0.2)

    except myTimeout:
        pass