Beispiel #1
0
 def __call__(self):
     self.argparser()
     self.conf=Confdir(self.args.confdir)
     if not self.args.path:
         firefoxPath=self.getFirefoxPath()
         print >>sys.stderr, "Using sessionstore from %s."%firefoxPath
     else: firefoxPath=self.args.path
         
     if self.args.sessionstore and self.firefoxIsOpen() \
         and raw_input("Browser must be closed first. Continue anyway? [y/N]") != "y":
         exit(1)
     Database.load(self.conf)
     sstore=Sessionstore(firefoxPath)
     if self.args.sessionstore:
         sstore.filterStorage(lambda url:self.isValidUrl(url) and Medium(url).downloadFinished())
         sstore.save()
     else:
         urls=sstore.getUrls()
         for i, url in enumerate(set(urls)):
                 if self.isValidUrl(url):
                     self._log("\tis valid motherless url")
                     sys.stdout.write("\r  ================>> %2.0f %%" % (100.0/len(urls)*i))
                     sys.stdout.flush()
                     m=Medium(url)
                     if (not m.isBeingDownloaded()) and (not Database.hasUrl(url)):
                         self._downloadThread(m)
         sys.stdout.write("\n")
     Database.close()
Beispiel #2
0
 def __call__(self):
     self.argparser()
     conf=Confdir(self.args.confdir)
     Database.load(conf)
     m=Medium(self.args.url)
     m.download(self.args.destination, conf, self.args.force)
     Database.close()
Beispiel #3
0
    def __init__(self, runtime:Runtime, medium:Medium, regions:List[ld.Region]=[ld.EU868,ld.US915]) -> None:
        self.runtime = runtime
        self.medium = medium
        self.regions = regions

        self.upframes:asyncio.Queue[LoraMsg] = asyncio.Queue()
        self.xmtr = LoraMsgTransmitter(runtime, medium)

        medium.add_listener(self)
Beispiel #4
0
 def __call__(self):
     self.argparser()
     conf=Confdir(self.args.confdir)
     Database.load(conf)
     with open(self.args.file) as f:
         l=["http://%s"%x for x in f.read().split("http://") if x != ""]
     for url in l:
         m=Medium(url)
         m.download(self.args.destination, conf, self.args.force)
     Database.close()
Beispiel #5
0
 def test_choose_blog_decline(self):
   ChooseBlog(self.request, self.response).finish(None)
   self.assertEquals(0, Medium.query().count())
   self.assertEquals(302, self.response.status_int)
   self.assertEquals(
     "http://localhost/#!OK, you're not signed up. Hope you reconsider!",
     urllib.unquote_plus(self.response.headers['Location']))
Beispiel #6
0
 def test_choose_blog_decline(self):
   ChooseBlog(self.request, self.response).finish(None)
   self.assertEquals(0, Medium.query().count())
   self.assertEquals(302, self.response.status_int)
   self.assertEquals(
     "http://localhost/#!OK, you're not signed up. Hope you reconsider!",
     urllib.unquote_plus(self.response.headers['Location']))
Beispiel #7
0
 def create_player(self, player_type, symbol):
     if player_type == 'user':
         return User(symbol, self.board)
     elif player_type == 'easy':
         return Easy(symbol, self.board)
     elif player_type == 'medium':
         return Medium(symbol, self.board)
     elif player_type == 'hard':
         return Hard(symbol, self.board)
Beispiel #8
0
def gameMaker(level):
    if level == 1:
        return Dumb()
    if level == 2:
        return Medium()
    if level == 3:
        return Smart()
    else:
        raise Exception('Level inválido')
 def testMediaToJSON(self):
     medium1 = Medium(555, 'Film', 'Testname', 'Action', 742, 'Testbeschreibung', 123456789)
     medium2 = Medium(666, 'Serie', 'Blubb', 'Drama', 73, 'Test Description', 7583743)
     
     media = Media()
     media.addMedium(medium1)
     media.addMedium(medium2)
     
     expected_json_string = "[" + medium1.to_json() + ", " + medium2.to_json() + "]"
     
     print("is: " + media.to_json())
     
     print("\nexpected: " + expected_json_string)
     
     result = sorted(json.loads(media.to_json()), key=itemgetter('media_id'))
     expected = sorted(json.loads(expected_json_string), key=itemgetter('media_id'))
     
     self.assertListEqual(result, expected)
Beispiel #10
0
 def test_choose_blog_decline(self):
     with app.test_request_context():
         with self.assertRaises(RequestRedirect) as rr:
             ChooseBlog('/unused').finish(None)
         self.assertEqual(0, Medium.query().count())
         self.assertEqual(302, rr.exception.code)
         self.assertEqual('http://localhost/', rr.exception.new_url)
         self.assertEqual(
             ["OK, you're not signed up. Hope you reconsider!"],
             get_flashed_messages())
Beispiel #11
0
 def init(self) -> None:
     self.reg = Radio.RadioRegister()
     self.sim.map_peripheral(self.pid, self.reg)
     self.medium: Medium = self.sim.context.get('medium', Medium())
     self.rcvr = LoraMsgReceiver(self.sim.runtime,
                                 self.medium,
                                 cb=self.rxdone)
     self.xmtr = LoraMsgTransmitter(self.sim.runtime,
                                    self.medium,
                                    cb=self.txdone)
Beispiel #12
0
  def test_choose_blog_publications(self):
    self.expect_get_publications(PUBLICATIONS)
    ChooseBlog(self.request, self.response).finish(self.auth_entity)
    self.assert_equals(200, self.response.status_code)
    for expected in ('action="/medium/add" method="post"',
                     '<input type="radio" name="blog" id="@ry"',
                     '<input type="radio" name="blog" id="b969ac62a46b"',
                     '<input type="radio" name="blog" id="b45573563f5a"',
                     ):
      self.assertIn(expected, self.response.text)

    self.assertEquals(0, Medium.query().count())
Beispiel #13
0
  def test_choose_blog_publications(self):
    self.expect_get_publications(PUBLICATIONS)
    ChooseBlog(self.request, self.response).finish(self.auth_entity)
    self.assert_equals(200, self.response.status_code)
    for expected in ('action="/medium/add" method="post"',
                     '<input type="radio" name="blog" id="@ry"',
                     '<input type="radio" name="blog" id="b969ac62a46b"',
                     '<input type="radio" name="blog" id="b45573563f5a"',
                     ):
      self.assertIn(expected, self.response.text)

    self.assertEquals(0, Medium.query().count())
Beispiel #14
0
  def assert_created_publication(self, medium=None):
    if not medium:
      mediums = list(Medium.query())
      self.assertEquals(1, len(mediums))
      medium = mediums[0]

    self.assertEquals('b45573563f5a', medium.key.id())
    self.assertEquals(self.auth_entity.key, medium.auth_entity)
    self.assertEquals('Developers', medium.name)
    self.assertEquals('https://medium.com/developers', medium.url)
    self.assertEquals('https://developers/image.png', medium.picture)
    self.assertTrue(medium.is_publication())
    self.assertEquals('https://medium.com/feed/developers', medium.feed_url())
    self.assertEquals('https://medium.com/developers', medium.silo_url())
Beispiel #15
0
  def assert_created_profile(self, medium=None):
    if not medium:
      mediums = list(Medium.query())
      self.assertEquals(1, len(mediums))
      medium = mediums[0]

    self.assertEquals('@ry', medium.key.id())
    self.assertEquals(self.auth_entity.key, medium.auth_entity)
    self.assertEquals('Ryan', medium.name)
    self.assertEquals('http://medium.com/@ry', medium.url)
    self.assertEquals('http://ava/tar', medium.picture)
    self.assertFalse(medium.is_publication())
    self.assertEquals('http://medium.com/feed/@ry', medium.feed_url())
    self.assertEquals('http://medium.com/@ry', medium.silo_url())
Beispiel #16
0
  def assert_created_publication(self, medium=None):
    if not medium:
      mediums = list(Medium.query())
      self.assertEquals(1, len(mediums))
      medium = mediums[0]

    self.assertEquals('b45573563f5a', medium.key.id())
    self.assertEquals(self.auth_entity.key, medium.auth_entity)
    self.assertEquals('Developers', medium.name)
    self.assertEquals('https://medium.com/developers', medium.url)
    self.assertEquals('https://developers/image.png', medium.picture)
    self.assertTrue(medium.is_publication())
    self.assertEquals('https://medium.com/feed/developers', medium.feed_url())
    self.assertEquals('https://medium.com/developers', medium.silo_url())
Beispiel #17
0
  def assert_created_profile(self, medium=None):
    if not medium:
      mediums = list(Medium.query())
      self.assertEquals(1, len(mediums))
      medium = mediums[0]

    self.assertEquals('@ry', medium.key.id())
    self.assertEquals(self.auth_entity.key, medium.auth_entity)
    self.assertEquals('Ryan', medium.name)
    self.assertEquals('http://medium.com/@ry', medium.url)
    self.assertEquals('http://ava/tar', medium.picture)
    self.assertFalse(medium.is_publication())
    self.assertEquals('http://medium.com/feed/@ry', medium.feed_url())
    self.assertEquals('http://medium.com/@ry', medium.silo_url())
Beispiel #18
0
    def test_choose_blog_publications(self):
        self.expect_get_publications(PUBLICATIONS)

        with app.test_request_context():
            resp = ChooseBlog('/unused').finish(self.auth_entity)
            for expected in (
                    'action="/medium/add" method="post"',
                    '<input type="radio" name="blog" id="@RY"',
                    '<input type="radio" name="blog" id="b969ac62a46b"',
                    '<input type="radio" name="blog" id="b45573563f5a"',
            ):
                self.assertIn(expected, resp)

        self.assertEqual(0, Medium.query().count())
def main():
    cord = Medium(100)
    pc1 = Device(cord, 4)
    pc1.add_message('1' * 100)
    pc1.add_message('1' * 100)
    pc1.add_message('1' * 100)
    pc2 = Device(cord, 70)
    pc2.add_message('1' * 100)
    pc2.add_message('1' * 100)
    pc2.add_message('1' * 100)

    for i in range(1000):
        print('iteration {}: '.format(i + 1), end='')
        cord.display()
        pc2.work()
        pc1.work()
        cord.propagate()
Beispiel #20
0
 def testMediumFromJSON(self):
     json_string = '{"media_id": 555, "media_type": "Film", "name": "Testname", "genre": "Action", "length": 742, "description": "Testbeschreibung", "size": 123456789}'
     expected_result = Medium(555, 'Film', 'Testname', 'Action', 742, 'Testbeschreibung', 123456789)
     result = Medium().from_json(json_string)
     self.assertDictEqual(result.return_dict(), expected_result.return_dict())
Beispiel #21
0
 def test_new_profile(self):
   self.assert_created_profile(
     Medium.new(self.handler, auth_entity=self.auth_entity, id='@ry'))
Beispiel #22
0
 def test_new_publication(self):
   self.assert_created_publication(
     Medium.new(self.handler, auth_entity=self.auth_entity, id='b45573563f5a'))
Beispiel #23
0
 def test_new_publication(self):
   self.assert_created_publication(
     Medium.new(self.handler, auth_entity=self.auth_entity, id='b45573563f5a'))
Beispiel #24
0
 def test_new_profile(self):
   self.assert_created_profile(
     Medium.new(self.handler, auth_entity=self.auth_entity, id='@ry'))
pygame.mixer.music.load('01 BGM #01.mp3')
pygame.mixer.music.play(-1)

# size of the grid
width = 16
height = 16
margin = 5
text = pygame.font.SysFont('Comic Sans MS', 10, True)
lev = "Game on"

num_bombs = 40
time_count = []
grid = []

easy = [Easy()]
medium = [Medium()]
difficult = [Difficult()]
level = [lev]


def ModePressed():
    pass


def delObjects():
    global grid
    global time_count
    global mode
    global lev
    global p_pressed
    p_pressed = 0
Beispiel #26
0
#
#
#     for line, data in zip(lines, dataLines):
#         # NOTE: there is no .set_data() for 3 dim data...
#         line.set_data(data[0:2, :num])
#         line.set_3d_properties(data[2, :num])


naccept = 0
nreject = 0
with open('first_setup.json') as json_file:
    input_json = json.load(json_file)

    nbofiterations = 300

    gliadin_medium = Medium(input_json['sequencea'], input_json['aminoacid'])
    mediumSize = gliadin_medium.getNbOfGliadin()
    #water

    old_energy = gliadin_medium.getEnergy()
    positionsHistory = pd.DataFrame()
    i = 1
    while i in range(nbofiterations):
        print("Iteration "+str(i))
        # Pick a random atom (random.randint(x,y) picks a random
        # integer between x and y, including x and y)

        selectedGliadin = rn.randint(0,mediumSize)-1;
        gliadin = gliadin_medium.getGliadin(selectedGliadin)
        print("start posities")
        print(gliadin.getPositions())
Beispiel #27
0
 def test_new_publication(self):
     self.assert_created_publication(
         Medium.new(auth_entity=self.auth_entity, username='******'))
Beispiel #28
0
 def test_new_profile(self):
     self.assert_created_profile(
         Medium.new(auth_entity=self.auth_entity, username='******'))
 def test_medium(self):
     profile_data = Medium.scrap('KeithSpencer', 'firefox')
     self.assertIsInstance(profile_data, dict)
     self.assertEqual(len(profile_data), 6)
Beispiel #30
0
            f.write(self.buffer)
        success(
            f"writing to {self.filename} with {self.buffer} successfully after TIMEOUT"
        )
        status("see you.")
        os._exit(1)
        # exit(0)

    def timeout_routine(self):
        while True:
            time.sleep(self.max_timeout)
            if self.received:
                self.received = False
                continue
            else:
                self.write_buffer_to_file()


try:
    status("start")

    medium = Medium(as_sender=False,
                    should_emulate_timeout=True,
                    emulate_timeout_fact=0.1,
                    max_timeout=10)
    receiver = Receiver(medium, "received_result.txt")
    receiver.medium.set_role(receiver)
    receiver.medium.run()
except Exception:
    os._exit(1)
Beispiel #31
0
 def testMediumToJSON(self):
     medium = Medium(555, 'Film', 'Testname', 'Action', 742, 'Testbeschreibung', 123456789)
     expected_result = '{"media_id": 555, "media_type": "Film", "name": "Testname", "genre": "Action", "length": 742, "description": "Testbeschreibung", "size": 123456789}'
     self.assertDictEqual(json.loads(medium.to_json()), json.loads(expected_result))