def __init__(self): authorizer = DummyAuthorizer() if getconfig('anonymous') == 'True': # 添加匿名用户 authorizer.add_anonymous(getconfig('dir'), perm='elradfmwM') else: # 添加用户,需要账号和密码登录 authorizer.add_user(getconfig('user'), getconfig('password'), getconfig('dir'), perm='elradfmwM') handler = FTPHandler # 初始化处理客户端命令的类 handler.authorizer = authorizer # 选择登录方式(是否匿名) # logging.basicConfig(filename='ftpd.log', level=logging.INFO) # 日志信息写入ftpd.log address = ('0.0.0.0', getconfig('port')) # 设置服务器的监听地址和端口 self.server = FTPServer(address, handler) self.server.max_cons = 256 # 给链接设置限制 self.server.max_cons_per_ip = 5
def __init__(self, *args, **kw): super().__init__(*args, **kw) # 创建panel panel = wx.Panel(self) font = wx.Font(11, wx.SWISS, wx.NORMAL, wx.NORMAL) # 创建复选框,并绑定事件 self.check = wx.CheckBox(panel, -1, '使用账户密码登录', pos=(20, 20), size=(200, -1)) self.check.SetFont(font) self.Bind(wx.EVT_CHECKBOX, self.onchecked) # 创建静态文本和文本输入框 self.userlabel = wx.StaticText(panel, label="用户名:", pos=(35, 45)) self.userlabel.SetFont(font) self.usertext = wx.TextCtrl(panel, -1, '', size=(95, 20), pos=(90, 42), style=wx.TE_READONLY) self.passlabel = wx.StaticText(panel, label="密码:", pos=(195, 45)) self.passlabel.SetFont(font) self.passtext = wx.TextCtrl(panel, -1, '', size=(95, 20), pos=(235, 42), style=wx.TE_PASSWORD) self.passtext.SetEditable(False) self.dirlabel = wx.StaticText(panel, label="FTP目录:", pos=(23, 72)) self.dirlabel.SetFont(font) self.dirtext = wx.TextCtrl(panel, -1, os.getcwd(), size=(215, 20), pos=(88, 70), style=wx.TE_READONLY) # 绑定退出事件 self.Bind(wx.EVT_CLOSE, self.onclose) # 创建按钮,并且绑定按钮事件 self.button = wx.Button(panel, -1, '更改', pos=(310, 70), size=(40, 20)) self.button.SetFont(wx.Font(9, wx.SWISS, wx.NORMAL, wx.NORMAL)) self.Bind(wx.EVT_BUTTON, self.onclick, self.button) self.portlabel = wx.StaticText(panel, label="FTP端口:", pos=(23, 104)) self.portlabel.SetFont(font) self.porttext = wx.TextCtrl(panel, -1, '21', size=(51, 20), pos=(88, 102)) self.startbutton = wx.Button(panel, -1, '启动FTP', pos=(160, 130), size=(70, 30)) self.startbutton.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL)) self.Bind(wx.EVT_BUTTON, self.startftp, self.startbutton) # 加载配置文件,使程序恢复到退出前的界面 if os.path.isfile('config.ini'): if getconfig('anonymous') == 'False': self.check.SetValue(1) self.usertext.SetEditable(1) self.passtext.SetEditable(1) self.usertext.SetValue(getconfig('user')) self.passtext.SetValue(getconfig('password')) self.porttext.SetValue(getconfig('port')) self.dirtext.SetValue(getconfig('dir')) self.urllabel = wx.StaticText(panel, label="", pos=(80, 170)) self.urllabel.SetFont(font)
# -*- coding: utf-8 -*- __author__ = 'sidon' from .model import Datasets from . import dbutil import utils # Based: http://css.dzone.com/articles/wxpython-and-sqlalchemy conf = utils.getconfig('') def addDataset(row): # O Dataset deve ser um dicionário dataset = Datasets() dataset.id_dataset = row['id_dataset'] dataset.espectro = row['espectro'] dataset.canal = row['canal'] dataset.descricao = row['descricao'] dataset.main_path = row['main_path'] dataset.nivel = row['nivel'] dataset.wavelet1 = row['wavelet1'] dataset.wavelet2 = row['wavelet2'] dataset.redutor1 = row['redutor1'] dataset.redutor2 = row['redutor2'] dataset.fredutor1 = row['fredutor1'] dataset.fredutor2 = row['fredutor2'] # dataset.clfful = row['clfful']
formatter = HtmlFormatter() return highlight(text, lexer, formatter) def xmldatetime(value): date = datetime.datetime.fromtimestamp(value) return date.strftime('%Y-%m-%d %H:%M') def lastupdatetime(nodes): try: ret = xmldatetime(nodes[0].timestamp) except IndexError: ret = xmldatetime(0) return ret def markdown(data): renderer = BleepRenderer() md = m.Markdown(renderer, extensions=m.EXT_FENCED_CODE | m.EXT_NO_INTRA_EMPHASIS) return md.render(data) def length(data): return len(data) configs = getconfig() app = configs.get('app') theme = configs.get('theme') env = Environment(loader=FileSystemLoader(os.path.join(app,'themes',theme,'templates'))) dfilter = {'xmldatetime':xmldatetime,'markdown':markdown,'length':length,'lastupdatetime':lastupdatetime} env.filters = dfilter env.globals = configs
# self.Re = int(getconfig("properties", "Re")) # self.A = float(getconfig("structure", "A")) # self.wnum = int(getconfig("structure", "wnum")) # self.base = 'calculate' # self.L = float(getconfig("structure", "L")) # self.v = float(getconfig("properties", "v")) # self.g = float(getconfig("properties", "g")) # self.ang = int(getconfig("properties", "ang")) # self.L_in = float(getconfig("structure", "L_in")) # self.L_out = float(getconfig("structure", "L_out")) # self.width = float(getconfig("structure", "width")) # self.structure = getconfig("structure", "structure") # self.realfiledir = '' # self.samedirecasflow = True files = [] Re = int(getconfig("properties", "Re")) A = float(getconfig("structure", "A")) wnum = int(getconfig("structure", "wnum")) base = 'calculate' L = float(getconfig("structure", "L")) v = float(getconfig("properties", "v")) sigma = float(getconfig("properties", "sigma")) density = float(getconfig("properties", "density")) g = float(getconfig("properties", "g")) ang = int(getconfig("properties", "ang")) L_in = float(getconfig("structure", "L_in")) L_out = float(getconfig("structure", "L_out")) width = float(getconfig("structure", "width")) air_speed = float(getconfig("properties", "air_speed")) structure = getconfig("structure", "structure") realfiledir = ''