def test_get_from_json(self):
        """Workspace._get_from_json"""
        json = {"name": "My Workspace", "id": "123abc"}

        ws = Workspace._get_from_json(json)

        self.assertEqual(ws.name, "My Workspace")
        self.assertEqual(ws.id, "123abc")
Example #2
0
 def __init__(self):
     """
     Main program core.
     Calculates the correlation based on the ratio of the pattern and the sliding window
     """
     self.workspace = Workspace(self.get_value_by_utc_time)
     self.corr_step = 3  # distance in seconds between two correlation detections
     self.wave_len = 1  # wave len in seconds
     self.experimental = 0  # enable experimental futures
Example #3
0
def load_data(data_dir, with_components=True):
    users = Users.parse_stream(open(os.path.join(data_dir, 'users.dat')))
    movies = Movies.parse_stream(open(os.path.join(data_dir, 'movies.dat')))
    ratings = Ratings.parse_stream(open(os.path.join(data_dir, 'ratings.dat')))

    w = Workspace(movies, ratings, users)
    w.summarize_users()
    w.summarize_movies()
    if with_components:
        w.extract_components()
    return users, movies, ratings
    def start_clockify_timer():
        """
        Starts a new Clockify Time Entry
        """
        # TODO add support for multiple Workspaces
        workspace = Workspace.get_all()[0]

        current_time = datetime.now().astimezone(pytz.utc)

        data = {"start": current_time.strftime("%Y-%m-%dT%H:%M:%SZ")}

        response = ClockifyApiCall(RequestTypes.POST, "workspaces/{}/time-entries".format(workspace.id), data=data)\
            .exec().json()
        return response
    def test_get_all(self, m_from_json):
        """Workspace.get_all"""
        response = MagicMock()
        self.m_clockify_api_exec.return_value = response
        response.json.return_value = [{"name": "WS1"}, {"name": "WS2"}]

        ws1 = MagicMock()
        ws2 = MagicMock()
        m_from_json.side_effect = [ws1, ws2]

        workspaces = Workspace.get_all()

        m_from_json.assert_has_calls(
            [call({"name": "WS1"}),
             call({"name": "WS2"})], any_order=True)

        self.assertEqual(len(workspaces), 2)
        self.assertTrue(ws1 in workspaces)
        self.assertTrue(ws2 in workspaces)
Example #6
0
        if 'q' in choice.lower():
            print("goodbye.")
            os._exit(0)
        else:
            try:
                dev = devs[int(choice)]
            except:
                continue

            shapeoko = XY(dev, bounds)
            break
    print(shapeoko.status())
    ε = shapeoko.register(XY.Empty())
    shapeoko.head = ε
    ws = Workspace(shapeoko)

    # test queuing
    ws.optimise_queue(True)
    ws.pause()
    imcb = lambda im:im.show()
    ws.enqueue(ε, [Vector(0,0)], lambda _:print(0), {}, {})
    ws.enqueue(ε, [Vector(0.05,0.05)], lambda _:print(1), {}, {})
    ws.enqueue(ε, [Vector(0.06,0.05)], lambda _:print(2), {}, {})
    ws.enqueue(ε, [Vector(0.05,0.04)], lambda _:print(3), {}, {})
    ws.enqueue(ε, [Vector(0.08,0.08)], lambda _:print(4), {}, {})
    ws.enqueue(ε, [Vector(0.05,0.05)], lambda _:print(5), {}, {})
    ws.enqueue(ε, [Vector(0.02,0.05)], lambda _:print(6), {}, {})
    ws.play()

    time.sleep(2)
Example #7
0
            print("goodbye.")
            os._exit(0)
        else:
            try:
                dev = devs[int(choice)]
            except:
                continue

            shapeoko = XY(dev, bounds)
            break
    print(shapeoko.status())
    ε = shapeoko.register(XY.Empty())
    ν = shapeoko.register(Needle())
    shapeoko.head = ε
    shapeoko.head = ν
    ws = Workspace(shapeoko)
    ws.optimise_queue(False)

    down = 0
    up = 15
    done = threading.Event()
    ws.enqueue(ν, [Vector(0,0)], lambda _:done.set(), {'down': up, 'up': up}, {})
    done.wait()
    input("Ready? ")

    while True:
        ws.enqueue(ν, [Vector(0,0), Vector(0,0.05), Vector(0.05,0.05), Vector(0.05,0)], lambda _:None, {'down': down, 'up': down}, {})



Example #8
0
 def clean_report(self):
     self.workspace = Workspace(self.get_value_by_utc_time)
    def test_hash(self):
        """Workspace.__hash__"""
        ws = Workspace("My Workspace", "123abc")

        self.assertEqual(hash(ws), hash("123abc"))
    def test_eq_equal(self):
        """Workspace.__eq__.equal"""
        ws1 = Workspace("My Workspace", "123abc")
        ws2 = Workspace("My Workspace", "123abc")

        self.assertEqual(ws1, ws2)
    def test_eq_diff_ids(self):
        """Workspace.__eq__.diff_ids"""
        ws1 = Workspace("My Workspace", "123abc")
        ws2 = Workspace("My Workspace", "def456")

        self.assertNotEqual(ws1, ws2)
    def test_repr(self):
        """Workspace.__repr__"""
        ws = Workspace("My Workspace", "123abc")

        self.assertEqual(repr(ws), "My Workspace")
    def test_init(self):
        """Workspace.__init__"""
        ws = Workspace("My Workspace", "123abc")

        self.assertEqual(ws.name, "My Workspace")
        self.assertEqual(ws.id, "123abc")
Example #14
0
    # coordinate system
    side = 1.
    iw, ih = im.dimensions
    factor = max(iw, ih) / side
    w, h = map(lambda v: v/factor, im.dimensions)

    # zoom levels
    z_σ = im.level_count // 2
    z_μ = 0

    # hardware
    virtual = XY(w, h)
    σ = virtual.register(Σ(Layer(im, z_σ, side)))
    μ = virtual.register(Μ(Layer(im, z_μ, side), (2592,1944)))
    p = virtual.register(Pen())
    ws = Workspace(virtual)

    # test queuing
    ws.optimise_queue(True)
    ws.pause()
    imcb = lambda im:im.show()
    ws.enqueue(σ, [Vector(0,0)], lambda _:print(0), {}, {})
    ws.enqueue(μ, [Vector(0.1065,0.1432)], lambda _:print(1), {'a':1}, {})
    ws.enqueue(μ, [Vector(0.2789,0.2809)], lambda _:print(2), {'a':2}, {})
    ws.enqueue(μ, [Vector(0.1012,0.2544)], lambda _:print(3), {'a':2}, {})
    ws.enqueue(μ, [Vector(0.1065,0.1432)], lambda _:print(4), {'a':2}, {})
    ws.enqueue(μ, [Vector(0.2789,0.2809)], lambda _:print(5), {'a':1}, {})
    ws.enqueue(μ, [Vector(0.1012,0.2544)], lambda _:print(6), {'a':1}, {})
    ws.play()

    # test canvas
Example #15
0
    else:
        if commit.hexsha.startswith(args.end_commit):
            in_range = True

        if in_range:
            passed_commits.append(commit)

        if commit.hexsha.startswith(args.start_commit):
            break

# Reverse to start with the oldest commit
passed_commits = list(reversed(passed_commits))
first_commit_start = datetime.fromtimestamp(passed_commits[0].authored_date)

# Check to see if there is a currently-running Clockify timer
workspace = Workspace.get_all()[0]
user_api_call = ClockifyApiCall(RequestTypes.GET, "/user")
user = user_api_call.exec().json()
timers_api_call = ClockifyApiCall(
    RequestTypes.GET,
    f"/workspaces/{workspace.id}/user/{user['id']}/time-entries")
timers = timers_api_call.exec().json()

if len(timers) > 0:
    top_timer = timers[0]
else:
    top_timer = None
timer_running = False
if top_timer and not top_timer["timeInterval"]["end"]:
    # Timer is running
    print("Timer is running!")
Example #16
0
            print("goodbye.")
            os._exit(0)
        else:
            try:
                dev = devs[int(choice)]
            except:
                continue

            shapeoko = XY(dev, bounds)
            break
    print(shapeoko.status())
    ε = shapeoko.register(XY.Empty())
    ν = shapeoko.register(Needle())
    shapeoko.head = ε
    shapeoko.head = ν
    ws = Workspace(shapeoko)
    ws.optimise_queue(False)

    down = 0
    up = 15
    done = threading.Event()
    ws.enqueue(ν, [Vector(0, 0)], lambda _: done.set(), {
        'down': up,
        'up': up
    }, {})
    done.wait()
    input("Ready? ")

    while True:
        ws.enqueue(ν, [
            Vector(0, 0),