<commit_before>from flask import Flask, request, redirect, render_template
from http.client import HTTPConnection
from pathlib import Path
from threading import Thread
from tkinter import Toplevel
from tkinter.ttk import Frame, Button, Label
from werkzeug import secure_filename
import logging
import netifaces
import os.path
import shutil
import socket
import time

from copilot.frame import CopilotInnerFrame
from copilot.options import OptionsFrame

log = logging.getLogger()

class FileServerFrame(CopilotInnerFrame):
    def __init__(self, master, config):
        super(FileServerFrame, self).__init__(master, config)

        self._frame_lbl['text'] = 'Upload Files'
        self._hide_next()

        ips = self._find_ips()
        http_addr = ''
        for ip in ips:
            http_addr += 'http://{}:{}'.format(ip, 4000)

        Label(self.master,
            text="To upload files, connect to:\n{}".format(http_addr),
            anchor='center', font=self._config.item_font
        ).grid(row=1, column=0, columnspan=2, sticky='ew')

        self.server = FileServer(4000, config)
        self.server.start()

    def _find_ips(self):
        ret_ips = []
        ifaces = netifaces.interfaces()
        for iface in ifaces:
            if iface[:2] == 'en':
                addrs = netifaces.ifaddresses(iface)
                inet_addrs = addrs.get(netifaces.AF_INET)
                ret_ips = [a['addr'] for a in inet_addrs]

        return ret_ips
<commit_msg>Show error when network connection isn't found<commit_after>from flask import Flask, request, redirect, render_template
from http.client import HTTPConnection
from pathlib import Path
from threading import Thread
from tkinter import Toplevel
from tkinter.ttk import Frame, Button, Label
from werkzeug import secure_filename
import logging
import netifaces
import os.path
import shutil
import socket
import time

from copilot.frame import CopilotInnerFrame
from copilot.options import OptionsFrame

log = logging.getLogger()

class FileServerFrame(CopilotInnerFrame):
    def __init__(self, master, config):
        super(FileServerFrame, self).__init__(master, config)

        self._frame_lbl['text'] = 'Upload Files'
        self._hide_next()

        ips = self._find_ips()
        http_addr = ''
        for ip in ips:
            http_addr += 'http://{}:{}'.format(ip, 4000)

        if len(http_addr) == 0:
            http_addr = 'Could not find network connection'

        self._lbl = Label(self.master,
            text="To upload files, connect to:\n{}".format(http_addr),
            anchor='center', font=self._config.item_font
        )
        self._lbl.grid(row=1, column=0, columnspan=2, sticky='ew')
        #self._lbl.configure(yscrollcommand=self._sb.set)
        #self._sb['command'] = self._lbl.yview

        self.server = FileServer(4000, config)
        self.server.start()

    def _find_ips(self):
        ret_ips = []
        ifaces = netifaces.interfaces()
        for iface in ifaces:
            if iface[:2] == 'en':
                addrs = netifaces.ifaddresses(iface)
                inet_addrs = addrs.get(netifaces.AF_INET)
                ret_ips = [a['addr'] for a in inet_addrs]

        return ret_ips

{'fraction_non_alphanumeric': 0.0995966490847037, 'fraction_numerical': 0.007756748371082842, 'mean_word_length': 2.8153846153846156, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7353704', 'n_tokens_mistral': 993, 'n_tokens_neox': 952, 'n_words': 255}