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()
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)
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
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)
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
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 = ''
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)
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'))
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 )
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()
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'))
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
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)
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')
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')
# 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()
def onListDoubleClick(e): if isinstance(e.window, windows.ChannelWindow): events.run("query %s" % e.target, e.window, e.window.network)
def query(): events.run('query %s' % target, e.window, e.window.network)
def _events(self, tick): events.run(tick, self.game, self)
def whois(): events.run('whois %s' % target, e.window, e.window.network)
def run(self, command): window = ui.windows.manager.get_active() events.run(command, window, window.network)
def onInvite(e): if not e.done and isautojoin(e.network, e.channel): events.run('join -n %s' % e.channel, e.window, e.network)
def onCommandSay(e): if isinstance(e.window, DebugWindow): events.run('raw '+' '.join(e.args), e.window, e.network)
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)