コード例 #1
0
    def on_enter(self, onsuccess=False):
        '''Series of actions to be performed when Schedule screen is entered
        '''

        self.ids.accordian_days.clear_widgets()
        from network import get_data

        # this should update the file on disk
        print onsuccess
        event = get_data('event', onsuccess=onsuccess)
        schedule = get_data('schedule', onsuccess=onsuccess)

        # read the file from disk
        app.event_name = event['name']
        app.venue_name = event['venue']
        start_date = event['start_date']
        end_date = event['end_date']

        dates = schedule['results'][0].keys()
        dates = sorted(dates,
                       key=lambda x: datetime.datetime.strptime(x, '%Y-%m-%d'))
        for date in dates:
            cday = Factory.AccordionItem(title=date)
            self.ids.accordian_days.add_widget(cday)
            sched = schedule['results'][0][date]

            items = len(sched)
            sv = ScrollView()
            gl = GridLayout(cols=4,
                            size_hint_y=None,
                            padding='2dp',
                            spacing='2dp')
            gl.bind(minimum_height=gl.setter('height'))
            for x in ['Time', 'Title', 'talk Type', 'Speaker']:
                ts = Factory.TimeSlice(text=x)
                gl.add_widget(ts)
            i = 0
            for i in xrange(0, items):
                start_time = sched[i]['start_time']
                end_time = sched[i]['end_time']
                l = Label(text="%s - %s" % (start_time, end_time))
                gl.add_widget(l)
                gl.add_widget(
                    Label(text=sched[i]['title'],
                          height='27dp',
                          size_hint_y=None))
                gl.add_widget(
                    Label(text=sched[i]['type'],
                          height='27dp',
                          size_hint_y=None))
                gl.add_widget(
                    Label(text=sched[i]['speaker_name'],
                          height='27dp',
                          size_hint_y=None))

                i += 1
            sv.add_widget(gl)
            cday.add_widget(sv)
コード例 #2
0
    def on_enter(self, onsuccess=False):
        from network import get_data
        community = get_data('community', onsuccess=onsuccess)

        if not community:
            return

        community = community.get('0.0.1')[0]

        self.ids.bcklbl.text = community['about']
        self.ids.aimg.source = community['photo']

        social_comm = community['social']
        # social_len = len(social_comm)
        app = App.get_running_app()
        gl = self.ids.container
        gl.clear_widgets()
        import webbrowser
        for social_acc, social_link in social_comm.items():
            imbt = Factory.ImBut()
            imbt.color = app.base_active_bright
            imbt.source = 'atlas://data/default/' + social_acc.lower()
            imbt.on_released = partial(webbrowser.open, social_link)
            gl.add_widget(imbt)

        Factory.Animation(opacity=1, d=.5).start(self.ids.main)
コード例 #3
0
 def on_enter(self, onsuccess=False):
     container = self.ids.main
     container.clear_widgets()
     data = get_data('devsprint', onsuccess=onsuccess).get('0.0.1', {})
     main = self.ids.main
     main.add_widget(Factory.devsprint(data=data))
     Factory.Animation(opacity=1, d=.5).start(container)
コード例 #4
0
    def on_enter(self):
        '''Series of actions to be performed when Schedule screen is entered
        '''
        
        self.ids.accordian_days.clear_widgets()
        from network import get_data

        # this should update the file on disk
        event = get_data('event')
        schedule = get_data('schedule')

        # read the file from disk
        app.event_name = event['name']
        app.venue_name = event['venue']
        start_date = event['start_date']
        end_date = event['end_date']
        
        dates = schedule['results'][0].keys()     

        for date in dates:
            cday = Factory.AccordionItem(title=date)
            self.ids.accordian_days.add_widget(cday)
            sched = schedule['results'][0][date]          
            items = len(sched)
            sv = ScrollView()
            gl = GridLayout(cols=1,
                            size_hint_y=None,
                            padding='2dp',
                            spacing='2dp')
            i = 0
            for i in xrange(0, items):
                app.start_time = sched[i]['start_time']
                app.end_time = sched[i]['end_time']
                ts = Factory.TimeSlice()
                gl.add_widget(ts)
                gl.add_widget(Label(text=sched[i]['title'], height='27dp',
                    size_hint_y=None))
                gl.add_widget(Label(text='Type: ' + sched[i]['type'],
                    height='27dp', size_hint_y=None))
                gl.add_widget(Label(text='Speaker: ' + sched[i]['speaker_name'],
                    height='27dp', size_hint_y=None))
                
                i+=1

            sv.add_widget(gl)
            cday.add_widget(sv)
コード例 #5
0
 def on_enter(self, onsuccess=False):
     container = self.ids.main
     container.clear_widgets()
     data = get_data('devsprint', onsuccess=onsuccess).get('0.0.1', {})
     main = self.ids.main
     main.add_widget(Factory.devsprint(data=data))
     Factory.Animation(opacity=1, d=.5).start(container)
     self.data = data
コード例 #6
0
    def on_enter(self, onsuccess=False):
        container = self.ids.container

        if self.from_back:
            Factory.Animation(opacity=1, d=.3).start(container)
            return

        if len(container.children) > 2:
            container.remove_widget(container.children[0])
        from network import get_data
        talks = get_data('tracks', onsuccess=onsuccess)
        gl = None
        if not talks:
            return
        try:
            talk_info = talks['0.0.1'][0][self.talkid]
        except KeyError:
            # no details for this talk exist...
            # let's go back to previous screen
            from utils import go_back_in_history
            go_back_in_history()
            return

        self.ids.talk_title.text = talk_info['title']
        self.ids.talk_desc.text = talk_info['description']
        if 'speaker' in talk_info.keys():
            speaker = talk_info['speaker']
            if speaker['name']:
                self._speaker_name = speaker['name']
                speaker_details = SpeakerDetails(speaker=speaker)
                if 'social' in speaker:
                    speaker_social = speaker['social']
                    items = speaker_social.items()
                    social_len = len(items)
                    gl = GridLayout(cols=social_len,
                                    size_hint_y=None,
                                    padding='2dp',
                                    spacing='2dp')
                    import webbrowser
                    # update data for share button
                    if 'proposal' in speaker_social:
                        self.ids.but_share.data = "Checkout this talk '" \
                            + speaker_social['proposal'] + "' by '"\
                            + speaker['name'] + "' @ http://Blockchaincon.io "
                    # display social buttons
                    for social_acc, social_link in items:
                        imbt = Factory.ImBut()
                        imbt.source = 'atlas://data/default/' + \
                            social_acc.lower()
                        imbt.on_released = partial(webbrowser.open,
                                                   social_link)
                        imbt.color = app.base_active_bright[:3] + [.9]
                        gl.add_widget(imbt)
                    speaker_details.add_widget(gl)
                self.ids.container.add_widget(speaker_details)
        Factory.Animation(opacity=1, d=.3).start(container)
        self.ids.scroll.scroll_y = 1
コード例 #7
0
    def on_enter(self, onsuccess=False):
        container = self.ids.container

        if self.from_back:
            Factory.Animation(opacity=1, d=.3).start(container)
            return

        if len(container.children) > 2:
                container.remove_widget(container.children[0])
        from network import get_data
        talks = get_data('tracks', onsuccess=onsuccess)
        gl = None
        if not talks:
            return
        try:
            talk_info = talks['0.0.1'][0][self.talkid]
        except KeyError:
            # no details for this talk exist...
            # let's go back to previous screen
            from utils import go_back_in_history
            go_back_in_history()
            return

        self.ids.talk_title.text = talk_info['title']
        self.ids.talk_desc.text = talk_info['description']
        if 'speaker' in talk_info.keys():
            speaker = talk_info['speaker']
            if speaker['name']:
                speaker_details = SpeakerDetails(speaker=speaker)
                if 'social' in speaker:
                    speaker_social = speaker['social']
                    items = speaker_social.items()
                    social_len = len(items)
                    gl = GridLayout(cols=social_len, size_hint_y=None,
                                    padding='2dp', spacing='2dp')
                    import webbrowser
                    # update data for share button
                    if 'proposal' in speaker_social:
                        self.ids.but_share.data = "Checkout this talk " \
                            + speaker_social['proposal'] + " by "\
                            + speaker['name']
                    # display social buttons
                    for social_acc, social_link in items:
                        imbt = Factory.ImBut()
                        imbt.source = 'atlas://data/default/' + \
                            social_acc.lower()
                        imbt.on_released = partial(
                            webbrowser.open, social_link)
                        imbt.color = app.base_active_bright[:3] + [.9]
                        gl.add_widget(imbt)
                    speaker_details.add_widget(gl)
                self.ids.container.add_widget(speaker_details)
        Factory.Animation(opacity=1, d=.3).start(container)
        self.ids.scroll.scroll_y = 1
コード例 #8
0
ファイル: main.py プロジェクト: madan-ram/code_and_command
    def run(self):
        number_of_iteration =  get_num_batch(len(self.file_list), self.batch_size)
        images_feature = None
        for batch_index in xrange(number_of_iteration):
            images = []
            for f in self.file_list[(batch_index) * self.batch_size: (batch_index+1) * self.batch_size]:

                # if image are not valid formate reject it
                try:
                    image = cv2.imread(sys.argv[1]+'/'+f)
                    if image is None:
                        raise Exception('image cannot be read')
                except Exception as e:
                        print e
                    	continue


                self.file_list_paths_success.append(sys.argv[1]+'/'+f)
                image = create_fixed_image_shape(image, frame_size=(227, 227, 3))
                images.append(image)
            images = np.asarray(images)
            input_image = np.transpose(images, (0, 3, 1, 2))

            # do lock on global net object
            network_lock.acquire()

            #  data from network, But you can replace with your own data source
            data, _ = network.get_data(net, input_image)
            network_lock.release()

            if images_feature is None:
                images_feature = data
            else:
                images_feature = np.vstack((images_feature, data))

        status_lock.acquire()


        if np.isnan(np.min(images_feature)):
            print "write data from thread_id->", self.thread_id, 'feature_shape', images_feature.shape, 'Found NaN'
            # images_feature = images_feature.nan_to_num()
        else:
            print "write data from thread_id->", self.thread_id, 'feature_shape', images_feature.shape


        CreateData.completed_chunks = CreateData.completed_chunks + 1
        print 'percentage of task completed', (CreateData.completed_chunks/float(len(chunks))) * 100, "images_feature shape", images_feature.shape
        print "created data from thread_id->", self.thread_id
        status_lock.release()

        self.q.put((images_feature, self.thread_id))
コード例 #9
0
    def on_enter(self, onsuccess=False):
        from network import get_data
        about = get_data('about', onsuccess=onsuccess)

        if not about:
            return

        about = about.get('0.0.1')[0]
        imbt = self.ids.imgbt
        imbt.source = about['logo']
        self.ids.but.on_released = partial(webbrowser.open, about['website'])

        self.ids.comm_desc.text = about['about']
        Factory.Animation(opacity=1, d=.5).start(self.ids.scroll)
コード例 #10
0
    def on_enter(self, onsuccess=False):
        '''Series of actions to be performed when Schedule screen is entered
        '''

        # this should update the file on disk
        sponsors = get_data('sponsors', onsuccess=onsuccess)
        if not sponsors:
            return

        sponsors = sponsors.get('0.0.1')
        main_box = self.ids.main
        main_box.clear_widgets()
        for s in sponsors:
            bl = Factory.Sponsor(size_hint_y=.8 / len(sponsors), data=s)
            main_box.add_widget(bl)
コード例 #11
0
    def on_enter(self, onsuccess=False):
        '''Series of actions to be performed when Schedule screen is entered
        '''

        # this should update the file on disk
        sponsors = get_data('sponsors', onsuccess=onsuccess)
        if not sponsors:
            return

        sponsors = sponsors.get('0.0.1')
        main_box = self.ids.main;
        main_box.clear_widgets()
        for s in sponsors:
            bl = Factory.Sponsor(size_hint_y=.8/len(sponsors), data=s)
            main_box.add_widget(bl)
        footer = Factory.Footer()
        main_box.add_widget(footer)
コード例 #12
0
    def on_enter(self, onsuccess=False):
        container = self.ids.container

        if self.from_back:
            return

        if len(container.children) > 2:
            container.remove_widget(container.children[0])
        from network import get_data
        talks = get_data('tracks', onsuccess=onsuccess)
        gl = None
        if not talks:
            return
        talk_info = talks['0.0.1'][0][self.talkid]

        self.ids.talk_title.text = talk_info['title']
        self.ids.talk_desc.text = talk_info['description']
        if 'speaker' in talk_info.keys():
            speaker = talk_info['speaker']
            if speaker['name']:
                speaker_details = SpeakerDetails(speaker=speaker)
                if 'social' in speaker:
                    speaker_social = speaker['social'][0]
                    social_len = len(speaker_social)
                    gl = GridLayout(cols=social_len,
                                    size_hint_y=None,
                                    padding='2dp',
                                    spacing='2dp')
                    import webbrowser
                    for social_acc, social_link in speaker_social.items():
                        imbt = Factory.ImBut()
                        imbt.source = 'atlas://data/default/' + social_acc.lower(
                        )
                        imbt.on_released = partial(webbrowser.open,
                                                   social_link)
                        gl.add_widget(imbt)
                    speaker_details.add_widget(gl)
                self.ids.container.add_widget(speaker_details)
        Factory.Animation(opacity=1, d=.3).start(container)
        self.ids.scroll.scroll_y = 1
コード例 #13
0
ファイル: blablub.py プロジェクト: joker234/spacegoo
def main(config, s):
	s.connect((config["ip"], config["port"]))
	io = s.makefile('rw')
	network.write('login %s %s' % (config["user"], config["password"]), io)

	planet_distance = ""

	while True:
		json_data = network.get_data(io)

		if json_data:
			if data.extract_winner(json_data):
				exit(0)

			own_id = data.extract_own_id(json_data)
			my_planets = data.extract_my_planets(json_data, own_id)
			enemy_planets = data.extract_enemy_planets(json_data, own_id)
			my_planet_id = data.extract_my_planet_ids(json_data, own_id)

			print "own_id: " + str(own_id)
			print "my_planets: " + str(my_planets)
			print "enemy_planets: " + str(enemy_planets)

			network.write("nop", io)
コード例 #14
0
ファイル: main.py プロジェクト: madan-ram/code_and_command
		for batch_index in xrange(number_of_iteration):
			images = []
			for f in file_list[(batch_index) * batch_size: (batch_index+1) * batch_size]:
				image = cv2.imread(sys.argv[1]+'/'+f)

				if image is None:
					continue

				image = create_fixed_image_shape(image, frame_size=(227, 227, 3))
				images.append(image)
			images = np.asarray(images)

			input_image = np.transpose(images, (0, 3, 1, 2))

			#  data from network, But you can replace with your own data source
			data, _ = network.get_data(net, input_image)

			# vertically append data to images_feature
			if images_feature is None:
				images_feature = data
			else:
				images_feature = np.vstack((images_feature, data))

			if batch_index%10 == 0:
				print ((batch_index+1)/float(number_of_iteration)) * 100, 'completed'

			if images_feature.shape[0]/batch_size_cluster == 1:
				print 'fiting model for data of shape', images_feature.shape
				clr.partial_fit(images_feature)
				images_feature = None
コード例 #15
0
    bounded_box_list = filter_by_boundray_ratio(
        filter_by_size(bounded_box_list))
    print "predicting labels for bounded box"

    images = []
    for bb in bounded_box_list:
        sub_img = img[bb[1]:bb[3], bb[0]:bb[2]]
        images.append(
            create_fixed_image_shape(sub_img,
                                     frame_size=network.IMAGE_SHAPE,
                                     mode='fit'))
    images = np.asarray(images)

    images = np.transpose(images, (0, 3, 1, 2))

    prob = network.get_data(net, images)
    max_label = np.argmax(prob, axis=1)
    max_label_prob = np.max(prob, axis=1)
    result = map_max_label_bb(map_id_word, bounded_box_list, max_label,
                              max_label_prob)

    for d in result:
        bb = d['bounded_box']
        label = d['label']
        if d['prob'] >= 0.2:
            color = generate_random_color()
            cv2.putText(img, label, (bb[0], bb[1]), cv2.FONT_HERSHEY_SIMPLEX,
                        1, color, 2)
            cv2.rectangle(img, (bb[0], bb[1]), (bb[2], bb[3]), color, 2)
    cv2.imwrite(sys.argv[2], img)
コード例 #16
0
    def on_enter(self, onsuccess=False):
        '''Series of actions to be performed when Schedule screen is entered
        '''
        container = self.ids.accordian_days
        # make sure the corresponding navigation is depressed
        app.navigationscreen.ids.left_panel.ids.bt_sched.state = 'down'
        # if the screen loads by pressing back, do nothing.
        if self.from_back == True:
            Factory.Animation(d=.5, opacity=1).start(container)
            return
        self.ids.accordian_days.clear_widgets()
        from network import get_data

        events = get_data('event', onsuccess=onsuccess)
        if not events:
            return

        schedule = get_data('schedule', onsuccess=onsuccess)
        if not schedule:
            return

        events = events.get('0.0.1')
        schedule = schedule.get('0.0.1')[0]

        # take first event as the one to display schedule for.
        self.event = event = events[0]
        app.event_name = event['name']
        app.venue_name = event['venue']
        start_date = event['start_date']
        end_date = event['end_date']
        
        dates = schedule.keys()[1:]
        # each day could have multiple tracks
        tracks = schedule['tracks']
        dates = sorted(
            dates,
            key=lambda x: datetime.datetime.strptime(x, '%Y-%m-%d'))

        # perf optims, minimize dot lookups
        acordion_add = self.ids.accordian_days.add_widget
        AccordionItem = Factory.AccordionItem
        Track = Factory.Track

        first = None
        today = datetime.datetime.now()
        
        for date in dates:
            # add current day as accordion widget
            ccday = datetime.datetime.strptime(date,"%Y-%m-%d")
            cday = AccordionItem(title=ccday.strftime("%d %b %Y"))

            if ccday.date()  >=  today.date():
                if not first: first = cday
            acordion_add(cday)
            day_sched = schedule[date]
            # create a carousel for each track
            tcarousel = TabbedCarousel()
            
            # this carousel would show each track as new tab
            trackscreens = []
            tsa = trackscreens.append
            tca = tcarousel.add_widget
            for track in tracks:
                new_trk = Track(name=track)
                tsa(new_trk)
                # add track to carousel
                tca(new_trk)
            
            for talk in day_sched:
                try:
                    stime  = "%s -- %s"%(date, talk['start_time'])
                    etime  = "%s -- %s"%(date, talk['end_time'])
                    stime = datetime.datetime.strptime(stime,"%Y-%m-%d -- %H:%M")
                    etime = datetime.datetime.strptime(etime,"%Y-%m-%d -- %H:%M")
                    talk['current'] = today > stime and today < etime
                except:
                    pass
                tid = talk['track']
                if tid.lower() == 'all':
                    for tlk in trackscreens:
                        tc = tlk.ids.container
                        ti = TalkInfo(talk=talk)
                        ti.color = (.5, .5, .5, .2) if len(tc.children)%2 == 0 else (.3, .3, .3, .2)
                        if talk['current']: ti.color = ti.color[:3] + [.8]
                        tc.add_widget(ti)
                    continue
                ti = TalkInfo(talk=talk)
                trackscreens[int(tid)-1].ids.container.add_widget(ti)

            cday.add_widget(tcarousel)
        if first: container.select(first)
        Factory.Animation(d=.5, opacity=1).start(container)
コード例 #17
0
    def on_enter(self, onsuccess=False):
        '''Series of actions to be performed when Schedule screen is entered
        '''
        container = self.ids.accordian_days
        # make sure the corresponding navigation is depressed
        app.navigationscreen.ids.left_panel.ids.bt_sched.state = 'down'
        # if the screen loads by pressing back, do nothing.
        if self.from_back is True:
            Factory.Animation(d=.5, opacity=1).start(container)
            return
        self.ids.accordian_days.clear_tabs()
        from network import get_data

        events = get_data('event', onsuccess=onsuccess)
        if not events:
            return

        schedule = get_data('schedule', onsuccess=onsuccess)
        if not schedule:
            return

        events = events.get('0.0.1')
        schedule = schedule.get('0.0.1')[0]

        # take first event as the one to display schedule for.
        self.event = event = events[0]
        app.event_name = event['name']
        app.venue_name = event['venue']
        # start_date = event['start_date']
        # end_date = event['end_date']

        dates = list(schedule.keys())
        dates.remove('tracks')
        # each day could have multiple tracks
        tracks = schedule['tracks']
        dates = sorted(
            dates,
            key=lambda x: datetime.datetime.strptime(x, '%Y-%m-%d'))

        # perf optims, minimize dot lookups
        acordion_add = self.ids.accordian_days.add_widget
        TI = Factory.TabbedPanelItem
        Track = Factory.Track

        first = None
        today = datetime.datetime.now()
        strt = datetime.datetime.strptime
        for date in dates:
            # add current day as accordion widget
            ccday = strt(date, "%Y-%m-%d")
            cday = TI(text=ccday.strftime("%d %b"))

            if not first:
                first = cday
            acordion_add(cday)
            day_sched = schedule[date]
            order, day_sched = day_sched[0]["order"], day_sched[1:]
            tracks = [schedule['tracks'][int(trk)-1] for trk in order]
            # create a carousel for each track
            tcarousel = TabbedCarousel()
            ti = TalkInfo

            # this carousel would show each track as new tab
            trackscreens = []
            tsa = trackscreens.append
            tca = tcarousel.add_widget
            for track in tracks:
                new_trk = Track(name=track,)
                tsa(new_trk)
                # add track to carousel
                tca(new_trk)

            for talk in day_sched:
                # try:
                #     stime = "%s -- %s" % (date, talk['start_time'])
                #     etime = "%s -- %s" % (date, talk['end_time'])
                #     stime = strt(stime, "%Y-%m-%d -- %H:%M")
                #     etime = strt(etime, "%Y-%m-%d -- %H:%M")
                #     talk['current'] = today > stime and today < etime
                # except:
                #     pass
                tid = talk['track']
                if tid.lower() == 'all':
                    for tlk in trackscreens:
                        ti = TalkInfo(talk=talk)
                        tlk.ids.container.add_widget(ti)
                    continue
                ti = TalkInfo(talk=talk)
                try:
                    trackscreens[int(tid)-1].ids.container.add_widget(ti)
                except IndexError:
                    pass

            cday.add_widget(tcarousel)
            if (ccday.day, ccday.month, ccday.year) ==\
               (today.day, today.month, today.year):
                first = cday
        if first:
            first.trigger_action()
            first = False
        Factory.Animation(d=.5, opacity=1).start(container)
コード例 #18
0
def main():
    # the data
    data = get_data(conv=True, doodle=False)

    train = np.array(data["train"])
    train = train.reshape(len(data["train"]), 28, 28, 1)
    goal = np.array(data["train_goal"])

    test = np.array(data["test"])

    test = test.reshape(len(data["test"]), 28, 28, 1)
    test_goal = np.array(data["test_goal"])

    ################################################
    # the model
    model = Sequential()

    model.add(Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1)))
    """
        model.add(Conv2D(64, (3, 3), activation='relu'))
        model.add(MaxPooling2D(pool_size=(2, 2)))
        model.add(Dropout(0.25))
    """
    model.add(Conv2D(64, (3, 3), activation='relu'))
    model.add(MaxPooling2D(pool_size=(2, 2)))
    model.add(Dropout(0.25))

    model.add(Flatten())
    model.add(Dense(200, activation='relu'))
    model.add(Dropout(0.5))
    model.add(Dense(10, activation='softmax'))
    ################################################

    sgd = SGD(lr=0.001, decay=1e-6, momentum=0.9, nesterov=True)

    # model.compile(loss='mean_squared_error', optimizer=sgd,
    #               metrics=['accuracy'])

    model.compile(loss='categorical_crossentropy',
                  optimizer='Adadelta',
                  metrics=['accuracy'])
    print("Ready")

    model.fit(train,
              goal,
              epochs=4,
              batch_size=128,
              verbose=1,
              validation_data=(test, test_goal))

    print("done")

    while True:
        name = input("Please enter the file name to save to (without .h5): ")
        try:
            model.save(name + ".h5")
            break
        except Exception as e:
            print(str(e))

    print("saved")
コード例 #19
0
    def on_enter(self, onsuccess=False):
        '''Series of actions to be performed when Schedule screen is entered
        '''
        container = self.ids.accordian_days
        # make sure the corresponding navigation is depressed
        app.navigationscreen.ids.left_panel.ids.bt_sched.state = 'down'
        # if the screen loads by pressing back, do nothing.
        if self.from_back is True:
            Factory.Animation(d=.5, opacity=1).start(container)
            return
        self.ids.accordian_days.clear_tabs()
        from network import get_data

        events = get_data('event', onsuccess=onsuccess)
        if not events:
            return

        schedule = get_data('schedule', onsuccess=onsuccess)
        if not schedule:
            return

        events = events.get('0.0.1')
        schedule = schedule.get('0.0.1')[0]

        # take first event as the one to display schedule for.
        self.event = event = events[0]
        app.event_name = event['name']
        app.venue_name = event['venue']
        # start_date = event['start_date']
        # end_date = event['end_date']

        dates = list(schedule.keys())
        dates.remove('tracks')
        # each day could have multiple tracks
        tracks = schedule['tracks']
        dates = sorted(
            dates,
            key=lambda x: datetime.datetime.strptime(x, '%Y-%m-%d'))

        # perf optims, minimize dot lookups
        acordion_add = self.ids.accordian_days.add_widget
        TI = Factory.TabbedPanelItem
        Track = Factory.Track

        first = None
        today = datetime.datetime.now()
        strt = datetime.datetime.strptime
        for date in dates:
            # add current day as accordion widget
            ccday = strt(date, "%Y-%m-%d")
            cday = TI(text=ccday.strftime("%d %b"))

            if not first:
                first = cday
            acordion_add(cday)
            day_sched = schedule[date]
            # create a carousel for each track
            tcarousel = TabbedCarousel()
            ti = TalkInfo

            # this carousel would show each track as new tab
            trackscreens = []
            tsa = trackscreens.append
            tca = tcarousel.add_widget
            for track in tracks:
                new_trk = Track(name=track,)
                tsa(new_trk)
                # add track to carousel
                tca(new_trk)

            for talk in day_sched:
                try:
                    stime = "%s -- %s" % (date, talk['start_time'])
                    etime = "%s -- %s" % (date, talk['end_time'])
                    stime = strt(stime, "%Y-%m-%d -- %H:%M")
                    etime = strt(etime, "%Y-%m-%d -- %H:%M")
                    talk['current'] = today > stime and today < etime
                except:
                    pass
                tid = talk['track']
                if tid.lower() == 'all':
                    for tlk in trackscreens:
                        ti = TalkInfo(talk=talk)
                        tlk.ids.container.add_widget(ti)
                    continue
                ti = TalkInfo(talk=talk)
                try:
                    trackscreens[int(tid)-1].ids.container.add_widget(ti)
                except IndexError:
                    pass

            cday.add_widget(tcarousel)
            if (ccday.day, ccday.month, ccday.year) ==\
               (today.day, today.month, today.year):
                first = cday
        if first:
            first.trigger_action()
            first = False
        Factory.Animation(d=.5, opacity=1).start(container)
コード例 #20
0
import sys
import string
import os

from opt.opt_parser import *
from opt.opt_config import *

from network.get_data import *

if __name__ == "__main__":
    parser = OptParser(get_opt_config())
    parsedOptions = parser.parse(sys.argv[1:])
    print("Perform ant algorithm with given options:\n", parsedOptions)

    # Assign parsed options to variables
    # function_type = FunctionType(parsedOptions["function"])
    # selection_type = SelectionType(parsedOptions["sel_type"])
    # replacement_type = ReplacementType(parsedOptions["rep_type"])
    # crossover_probability = parsedOptions["crossover_p"]
    # dimensions = parsedOptions["dimensions"]
    # iterations = parsedOptions["iterations"]
    # cardinality = parsedOptions["cardinality"]
    # attempts = parsedOptions["attempts"]
    # mut_range = parsedOptions["mut_sigma"]
    # x_min = parsedOptions["x_min"]
    # x_max = parsedOptions["x_max"]

    netmap = get_data('network/usa.xml')

    print("OK")