Пример #1
0
    def nick_change(self, entry):
        oldnick, newnick = self.label.get_text(), entry.get_text()
        
        if newnick and newnick != oldnick:
            events.run('nick %s' % newnick, self.win, self.win.network)

        self.win.input.grab_focus()
Пример #2
0
def onConnect(e):
    if conf.get('debug'):
        debug = get_debug(e.network)
        if debug:
            windows.mutate(DebugWindow, e.network, debug.id)
        else:
            events.run('debug', e.window, e.network)
Пример #3
0
def setupJoin(e):
    if e.source == e.network.me:
        if not hasattr(e.network,'_ialwhos'):
            e.network._ialwhos = {}
        e.network._ialwhos[e.target] = True
        events.run('raw WHO '+e.target,e.window,e.network)
    else:
        e.network._ial[e.source] = e.address
Пример #4
0
    def trigger_start():
        events.trigger("Start")
        
        window = windows.manager.get_active()
        
        if not window:
           window = windows.new(windows.StatusWindow, irc.Network(), "status")
           window.activate()

        events.run(command, window, window.network)
Пример #5
0
def setupInput(e):
    if not e.done:
        if e.text.startswith(COMMAND_PREFIX) and not e.ctrl:
            command = e.text[len(COMMAND_PREFIX):]
        else:
            command = 'say - %s' % e.text

        events.run(command, e.window, e.network)
        
        e.done = True
Пример #6
0
 def entered_text(self, ctrl):
     #FIXME: move this logic into Window
     for line in self.text.splitlines():
         if line:
             e_data = events.data(
                         window=self.win, network=self.win.network,
                         text=line, ctrl=ctrl
                         )
             events.trigger('Input', e_data)
             
             if not e_data.done:
                 events.run(line, self.win, self.win.network)
     
     self.text = ''
Пример #7
0
def onCommandIrcurl(e):
    url = e.args[0]
    
    if url.startswith('irc://'):
        url = url[6:]
        
        if not url.startswith('/'):
            host, target = url.rsplit('/',1)
            if ':' in host:
                host, port = host.rsplit(':',1)
            else:
                port = 6667
        else:
            host = None
            port = 6667
            target = url
        
        if host:
            if e.network and e.network.server == host:
                network = e.network
            else:
                for w in list(windows.manager):
                    if w.network and w.network.server == host:
                        network = w.network
                        break
                else:
                    for w in list(windows.manager):
                        if w.network and w.network.server == 'irc.default.org':
                            network = server(host,port,w.network)
                            break
                    else:
                        network = server(host,port)
        
        if ',' in target:
            target, modifiers = target.split(',',1)
            action = ''
        else:
            target = unquote(target)
            if target[0] not in '#&+':
                target = '#'+target
            action = 'join %s' % target
        
        if network.status == irc.CONNECTED:
            events.run(action, windows.get_default(network), network)
        else:
            if not hasattr(network,'temp_perform'):
                network.temp_perform = [action]
            else:
                network.temp_perform.append(action)
Пример #8
0
def getstarted():
    if current_user.is_authenticated:
        u = current_user.user_auth
        if u.credentials == 1:
            key = decode(u.api_key)
            print key
        else:
            key = " "
        if request.method == 'POST':
            if request.form.get('key'):
                if (request.form.get('key').startswith('sk_live') or request.form.get('key').startswith('sk_test'))\
                        and len(request.form.get('key')) == 32:
                    u.api_key = encode(request.form.get('key'))
                    u.credentials = 1
                    session['api_key'] = request.form.get('key')
                    db.session.commit()

                    #flash(_('Successfully updated API credentials'), 'success')
                    stripe.api_key = session['api_key']
                    events, current, per, churn, ltv = run()
                    return render_template('pages/index.html',
                                           events=events,
                                           mrr=current[0],
                                           refunds=current[1],
                                           net_revenue=current[2],
                                           annual=current[3],
                                           customers=current[4],
                                           new_customers=current[5],
                                           arpu=current[6],
                                           canceled=current[7],
                                           upgrades=current[8],
                                           downgrades=current[9],
                                           mrrP=per[0],
                                           refundsP=per[1],
                                           net_revenueP=per[2],
                                           annualP=per[3],
                                           customersP=per[4],
                                           new_customersP=per[5],
                                           arpuP=per[6],
                                           canceledP=per[7],
                                           upgradesP=per[8],
                                           downgradesP=per[9],
                                           churn=churn,
                                           ltv=ltv)
                else:
                    u.credentials = 0
                    session['api_key'] = ""
                    db.session.commit()
                    flash(
                        _('Your API credentials were invalid, please enter them again.'
                          ), 'error')
                    return render_template('pages/getstarted.html')
            else:
                flash(_('API credentials required.'), 'error')
                return render_template('pages/getstarted.html')

        return render_template('pages/getstarted.html', key=key)
    else:
        return redirect(url_for('user.login'))
Пример #9
0
 def on_connect(self, button):
     model, iter = self.networks.get_selection().get_selected()
     
     if iter:
         network_name = model.get_value(iter, 0)
         window = windows.manager.get_active()
         network = window.network
         
         if network and network.status:
             switches = 'm'
         else:
             switches = ''
         
         events.run(
             'server -%s %s' % (switches, network_name),
             window,
             network
             )
Пример #10
0
def onClick(e):
    set_target(e)

    if is_nick(e):
        events.run('query %s' % e._target, e.window, e.window.network)
    
    # url of the form http://xxx.xxx or www.xxx.xxx       
    elif is_url(e):
        if e._target.startswith('www'):
            e._target = 'http://%s' % e._target
        ui.open_file(e._target)
    
    # click on a #channel
    elif is_chan(e):
        if not chaninfo.ischan(e.window.network, e._target):
            e.window.network.join(e._target)
        window = windows.get(windows.ChannelWindow, e.window.network, e._target)
        if window:
            window.activate()
Пример #11
0
def getstarted():
    if current_user.is_authenticated:
        u = current_user.user_auth
        if u.credentials == 1:
            key = decode(u.api_key)
            print key
        else:
            key = " "
        if request.method == 'POST':
            if request.form.get('key'):
                if (request.form.get('key').startswith('sk_live') or request.form.get('key').startswith('sk_test'))\
                        and len(request.form.get('key')) == 32:
                    u.api_key = encode(request.form.get('key'))
                    u.credentials = 1
                    session['api_key'] = request.form.get('key')
                    db.session.commit()

                    #flash(_('Successfully updated API credentials'), 'success')
                    stripe.api_key = session['api_key']
                    events, current, per, churn, ltv = run()
                    return render_template('pages/index.html', events=events, mrr=current[0], refunds=current[1],
                                           net_revenue=current[2],
                                           annual=current[3], customers=current[4], new_customers=current[5],
                                           arpu=current[6],
                                           canceled=current[7], upgrades=current[8], downgrades=current[9], mrrP=per[0],
                                           refundsP=per[1],
                                           net_revenueP=per[2], annualP=per[3], customersP=per[4],
                                           new_customersP=per[5], arpuP=per[6],
                                           canceledP=per[7], upgradesP=per[8], downgradesP=per[9], churn=churn, ltv=ltv)
                else:
                    u.credentials = 0
                    session['api_key'] = ""
                    db.session.commit()
                    flash(_('Your API credentials were invalid, please enter them again.'), 'error')
                    return render_template('pages/getstarted.html')
            else:
                flash(_('API credentials required.'), 'error')
                return render_template('pages/getstarted.html')

        return render_template('pages/getstarted.html', key=key)
    else:
        return redirect(url_for('user.login'))
Пример #12
0
def onConnect(e):
    network_info = conf.get('networks', {}).get(e.network.name, {})

    for command in network_info.get('perform', []):
        while command.startswith(COMMAND_PREFIX):
            command = command[len(COMMAND_PREFIX):]
        events.run(command, e.window, e.network)
    
    tojoin = ','.join(network_info.get('join', []))
    if tojoin:
        events.run('join -n %s' % tojoin, e.window, e.network)
    
    if hasattr(e.network,'temp_perform'):
        for command in e.network.temp_perform:
            events.run(command, e.window, e.network)
        del e.network.temp_perform
Пример #13
0
def onCommandIalupdate(e):
    e.network._ial = {}
    e.network._ialwhos = {}
    if e.args:
        who = e.args[0]
        if who.startswith('#'):
            if who in chaninfo.channels(e.network):
                e.window.write('* Updating IAL for channel %s.' % who)
                e.network._ialwhos[who] = True
                events.run('raw WHO '+who,e.window,e.network)
            else:
                e.window.write('* You are not on channel %s.' % who)
        elif can_see(who):
            e.window.write('* Updating IAL for %s.' % who)
            e.network._ialwhos[who] = True
            events.run('raw WHO '+who,e.window,e.network)
        else:
            e.window.write('* %s is not a valid nick/channel.' % who)
    else:
        e.window.write('* Updating IAL for every channel.')
        for window in chaninfo.channels(e.network):
            e.network._ialwhos[window] = True
            events.run('raw WHO '+window,e.window,e.network)
Пример #14
0
def home():
    if current_user.is_authenticated:
        # check to see if items are in session, this helps us to not make multiple API calls
        if 'api_key' in session:
            stripe.api_key = session['api_key']
        if 'events' in session:
            if len(session['events']) > 0:
                events = []
                for y in session['events'][0:19]:
                    x = json.loads(y)
                    p_date = pretty_date(x['dateint'])
                    event = Event(x['amount'], x['dateint'], x['date'],
                                  x['name'], x['type'], x['plan'], p_date,
                                  x['customer_id'])

                    events.append(event)

                current = session['current']
                per = session['percentages']
                churn = session['churn']
                ltv = session['ltv']

                return render_template('pages/index.html',
                                       events=events,
                                       mrr=current[0],
                                       refunds=current[1],
                                       net_revenue=current[2],
                                       annual=current[3],
                                       customers=current[4],
                                       new_customers=current[5],
                                       arpu=current[6],
                                       canceled=current[7],
                                       upgrades=current[8],
                                       downgrades=current[9],
                                       mrrP=per[0],
                                       refundsP=per[1],
                                       net_revenueP=per[2],
                                       annualP=per[3],
                                       customersP=per[4],
                                       new_customersP=per[5],
                                       arpuP=per[6],
                                       canceledP=per[7],
                                       upgradesP=per[8],
                                       downgradesP=per[9],
                                       churn=churn,
                                       ltv=ltv)
            else:
                clear_session()  # clear the empty session
                events, current, per, churn, ltv = run()
                stripeErrors = returnErrors()
                if stripeErrors.AuthenticationError:
                    print stripeErrors.AuthenticationError
                    u = current_user.user_auth
                    u.credentials = 0
                    db.session.commit()
                    flash(
                        _('Your API credentials were invalid, please enter them again.'
                          ), 'error')
                    return render_template('pages/getstarted.html')
                elif stripeErrors.APIConnectionError:
                    print stripeErrors.APIConnectionError
                    flash(
                        _('Trouble connecting to Stripe. Please wait a minute and try again.'
                          ), 'error')
                    return render_template('pages/getstarted.html')
                else:
                    return render_template('pages/index.html',
                                           events=events,
                                           mrr=current[0],
                                           refunds=current[1],
                                           net_revenue=current[2],
                                           annual=current[3],
                                           customers=current[4],
                                           new_customers=current[5],
                                           arpu=current[6],
                                           canceled=current[7],
                                           upgrades=current[8],
                                           downgrades=current[9],
                                           mrrP=per[0],
                                           refundsP=per[1],
                                           net_revenueP=per[2],
                                           annualP=per[3],
                                           customersP=per[4],
                                           new_customersP=per[5],
                                           arpuP=per[6],
                                           canceledP=per[7],
                                           upgradesP=per[8],
                                           downgradesP=per[9],
                                           churn=churn,
                                           ltv=ltv)
        # otherwise make an api call
        else:
            events, current, per, churn, ltv = run()
            stripeErrors = returnErrors()
            if stripeErrors.AuthenticationError:
                print stripeErrors.AuthenticationError
                u = current_user.user_auth
                u.credentials = 0
                db.session.commit()
                flash(
                    _('Your API credentials were invalid, please enter them again.'
                      ), 'error')
                return render_template('pages/getstarted.html')
            elif stripeErrors.APIConnectionError:
                print stripeErrors.APIConnectionError
                flash(
                    _('Trouble connecting to Stripe. Please wait a minute and try again.'
                      ), 'error')
                return render_template('pages/getstarted.html')
            else:
                return render_template('pages/index.html',
                                       events=events,
                                       mrr=current[0],
                                       refunds=current[1],
                                       net_revenue=current[2],
                                       annual=current[3],
                                       customers=current[4],
                                       new_customers=current[5],
                                       arpu=current[6],
                                       canceled=current[7],
                                       upgrades=current[8],
                                       downgrades=current[9],
                                       mrrP=per[0],
                                       refundsP=per[1],
                                       net_revenueP=per[2],
                                       annualP=per[3],
                                       customersP=per[4],
                                       new_customersP=per[5],
                                       arpuP=per[6],
                                       canceledP=per[7],
                                       upgradesP=per[8],
                                       downgradesP=per[9],
                                       churn=churn,
                                       ltv=ltv)
    else:
        #flash(_('Please login or signup to access this page.'), 'error')
        return render_template('pages/welcome.html')
Пример #15
0
def home():
    if current_user.is_authenticated:
        # check to see if items are in session, this helps us to not make multiple API calls
        if 'api_key' in session:
            stripe.api_key = session['api_key']
        if 'events' in session:
            if len(session['events']) > 0:
                events = []
                for y in session['events'][0:19]:
                    x = json.loads(y)
                    p_date = pretty_date(x['dateint'])
                    event = Event(x['amount'], x['dateint'], x['date'], x['name'], x['type'], x['plan'],
                                  p_date,
                                  x['customer_id'])

                    events.append(event)

                current = session['current']
                per = session['percentages']
                churn = session['churn']
                ltv = session['ltv']

                return render_template('pages/index.html', events=events, mrr=current[0], refunds=current[1],
                                       net_revenue=current[2],
                                       annual=current[3], customers=current[4], new_customers=current[5],
                                       arpu=current[6],
                                       canceled=current[7], upgrades=current[8], downgrades=current[9], mrrP=per[0],
                                       refundsP=per[1],
                                       net_revenueP=per[2], annualP=per[3], customersP=per[4], new_customersP=per[5],
                                       arpuP=per[6],
                                       canceledP=per[7], upgradesP=per[8], downgradesP=per[9], churn=churn, ltv=ltv)
            else:
                clear_session()  # clear the empty session
                events, current, per, churn, ltv = run()
                stripeErrors = returnErrors()
                if stripeErrors.AuthenticationError:
                    print stripeErrors.AuthenticationError
                    u = current_user.user_auth
                    u.credentials = 0
                    db.session.commit()
                    flash(_('Your API credentials were invalid, please enter them again.'), 'error')
                    return render_template('pages/getstarted.html')
                elif stripeErrors.APIConnectionError:
                    print stripeErrors.APIConnectionError
                    flash(_('Trouble connecting to Stripe. Please wait a minute and try again.'), 'error')
                    return render_template('pages/getstarted.html')
                else:
                    return render_template('pages/index.html', events=events, mrr=current[0], refunds=current[1],
                                           net_revenue=current[2], annual=current[3], customers=current[4],
                                           new_customers=current[5], arpu=current[6], canceled=current[7],
                                           upgrades=current[8], downgrades=current[9], mrrP=per[0], refundsP=per[1],
                                           net_revenueP=per[2], annualP=per[3], customersP=per[4],
                                           new_customersP=per[5],
                                           arpuP=per[6], canceledP=per[7], upgradesP=per[8], downgradesP=per[9],
                                           churn=churn,
                                           ltv=ltv)
        # otherwise make an api call
        else:
            events, current, per, churn, ltv = run()
            stripeErrors = returnErrors()
            if stripeErrors.AuthenticationError:
                print stripeErrors.AuthenticationError
                u = current_user.user_auth
                u.credentials = 0
                db.session.commit()
                flash(_('Your API credentials were invalid, please enter them again.'), 'error')
                return render_template('pages/getstarted.html')
            elif stripeErrors.APIConnectionError:
                print stripeErrors.APIConnectionError
                flash(_('Trouble connecting to Stripe. Please wait a minute and try again.'), 'error')
                return render_template('pages/getstarted.html')
            else:
                return render_template('pages/index.html', events=events, mrr=current[0], refunds=current[1],
                                       net_revenue=current[2],
                                       annual=current[3], customers=current[4], new_customers=current[5],
                                       arpu=current[6],
                                       canceled=current[7], upgrades=current[8], downgrades=current[9], mrrP=per[0],
                                       refundsP=per[1],
                                       net_revenueP=per[2], annualP=per[3], customersP=per[4], new_customersP=per[5],
                                       arpuP=per[6],
                                       canceledP=per[7], upgradesP=per[8], downgradesP=per[9], churn=churn,
                                       ltv=ltv)
    else:
        #flash(_('Please login or signup to access this page.'), 'error')
        return render_template('pages/welcome.html')
Пример #16
0
        # when click to disconnect
        else:
            is_connected = not is_connected
            window['-connect-'].update(text='connect')
            window['-status-'].update(image_data=icon_status_off)
    if event == '-pi-':
        if not is_connected:
            sg.popup_no_titlebar('Connect first!', background_color='red')
        else:
            sg.popup('Pi info', get_pi_info(values['-host-'], values['-port-']))
    if event == '-device-':
        if not is_connected:
            sg.popup_no_titlebar('Connect first!', background_color='red')
        else:
            # Listbox has select mod , used to determine if only 1 item can be selected or multiple
            device = values['-device-'][0]
            # update device description
            window['-description-'].update(value=eval('D_{}'.format(device)))
            # create new window
            window2 = sg.Window('run')
            # normal close or except Exception will close window
            try:
                run(window2, device, values['-host-'], values['-port-'])
            except Exception as e:
                sg.popup_no_titlebar(e, background_color='red')
            finally:
                window2.close()
    if event in (sg.WIN_CLOSED, 'Exit'):
        break
window.close()
Пример #17
0
def onListDoubleClick(e):
    if isinstance(e.window, windows.ChannelWindow):
        events.run("query %s" % e.target, e.window, e.window.network)
Пример #18
0
 def query():
     events.run('query %s' % target, e.window, e.window.network)
Пример #19
0
 def _events(self, tick):
     events.run(tick, self.game, self)
Пример #20
0
 def whois():
     events.run('whois %s' % target, e.window, e.window.network)
Пример #21
0
 def run(self, command):
     window = ui.windows.manager.get_active()
     events.run(command, window, window.network)
Пример #22
0
def onInvite(e):
    if not e.done and isautojoin(e.network, e.channel):
        events.run('join -n %s' % e.channel, e.window, e.network)
Пример #23
0
def onCommandSay(e):
    if isinstance(e.window, DebugWindow):
        events.run('raw '+' '.join(e.args), e.window, e.network)
Пример #24
0
 def __call__(self, e):
     loc = sys.modules.copy()
     loc.update(e.__dict__)
     result = eval(self.command,loc)
     if isinstance(result,basestring):
         events.run(result,e.window,e.network)