Commit 0a37816286563f8b01939ca99479c550be8e39ab

Light cleanup, restore login support
  
8181
8282class Config(object):
8383
84 CONFIG_VERSION = '2.0-alpha6'
84 CONFIG_VERSION = '2.0-alpha6.1'
8585
8686
8787 def __init__(self):
133133
134134 self.config_obj = { 'version' : Config.CONFIG_VERSION,
135135 'path_set' : False,
136 'backup' : 'backup',
136 'backup' : False,
137137 'upl_maxthreads' : 2,
138138 'upl_scale' : 100,
139139 'em_token' : '21E34B5ADA0',
  
7171
7272
7373 # Load config
74 c = Config()
75 r = c.reinit
74 config = Config()
75 r = config.reinit
7676 if r == -1:
7777 dlg = wx.MessageDialog(self, """The uploader client configuration has been reset since an old configuration file was found.
7878 Please check your configuration (such as user login and EVE path).""", 'Client Upgrade', wx.OK | wx.ICON_INFORMATION)
9797 wx.PostEvent(this, evt)
9898 self.updcb = updcb
9999
100 config = Config()
101100 self.uploader = get_uploader(config, updcb)
102101
103102 # Set icon
104
105103 self.SetIcon(images.getIconIcon())
106104
107105 # Task Bar
108
109106 self.tbicon = TaskBarIcon(self)
110107
111
112108 # Create the menubar
113109 menuBar = wx.MenuBar()
114110
131131
132132 menu.Append(wx.ID_EXIT, "E&xit\tAlt-X", "Exit")
133133
134
135
136
137
138134 helpmenu.Append(self.MENU_ABOUT, "&About")
139135
140136 # bind the menu event to an event handler
153153 # Now create the Panel to put the other controls on.
154154 panel = wx.Panel(self)
155155
156 # and a few controls
157 # text = wx.StaticText(panel, -1, "EVE-Central.com MarketUploader")
158
159156 self.pathtext = wx.StaticText(panel, -1, "Please wait...")
160# self.pathtext.Enable(False)
161157 self.pathtext_l = wx.StaticText(panel, -1, "Using folder: ")
162158
163159 self.usertext_l = wx.StaticText(panel, -1, "Character name: ")
161161
162162 self.uploadtext = wx.StaticText(panel, -1, "")
163163
164 config_obj = Config()
165
166 if config_obj['character_id'] == 0:
164 if config['character_id'] == 0:
167165 self.uploads = long(0)
168166 else:
169 self.uploads = get_charuploads(config_obj['character_id'])
167 self.uploads = get_charuploads(config['character_id'])
170168 self.scans = 0
171169
172170
213213 self.load_infowidgets()
214214
215215 def load_infowidgets(self):
216 config_obj = Config()
216 config = Config()
217217
218 path = config_obj['evepath'][0]
218 path = config['evepath'][0]
219219 if (path):
220220 self.pathtext.SetLabel( path)
221 self.usertext.SetLabel(config_obj['character_name'])
221 self.usertext.SetLabel(config['character_name'])
222222 self.uploadtext.SetLabel("Uploads so far: " + `self.uploads`[:-1] + " Scans so far: " + `self.scans`)
223223
224224 def OnOptions(self, evt):
225 config = Config()
225226 dlg = evec_upload.options.OptionDialog(self)
226 dlg.ShowModal()
227 r = dlg.ShowModal()
228 if r == wx.ID_OK:
229 config['backup'] = dlg.backup.GetValue()
230 if dlg.anon_cb.IsChecked():
231 config['character_name'] = "Anonymous"
232 config['character_id'] = 0
233 else:
234 v = get_charid(dlg.uname.GetValue(), dlg.passwd.GetValue())
235 if v == -1:
236 dlge = wx.MessageDialog(self, 'User login information incorrect. Using old value', 'Bad login',
237 wx.OK | wx.ICON_ERROR
238 )
239 dlge.ShowModal()
240 dlge.Destroy()
241 else:
242 config['character_id'] = v
243 config['character_name'] = dlg.uname.GetValue()
244 config.save_config()
245 self.load_infowidgets()
227246
247
248
249 else:
250 pass
251 dlg.Destroy()
252
253
228254 def OnTimeToClose(self, evt):
229255 """Event handler for the button click."""
230256 self.tbicon.OnTaskBarQuit(None)
283283
284284
285285 def OnTimer(self, evt):
286 config_obj = Config()
286 config = Config()
287287 self.SetStatusText("Uploading...")
288288
289 job = UploadPayload(config_obj['evepath'][0], self.uploader, self.donecb)
289 job = UploadPayload(config['evepath'][0], self.uploader, self.donecb)
290290 self.upload_thread.trigger(job)
291291
292292
293293 def OnLocate(self, evt):
294 config_obj = Config()
294 config = Config()
295295 dlg = wx.DirDialog(self, "Please locate the cache folder",
296296 style=wx.DD_DEFAULT_STYLE,
297297 defaultPath=default_location() )
298298
299299 if dlg.ShowModal() == wx.ID_OK:
300300 print os.path.abspath(dlg.GetPath())
301 config_obj['evepath'][0] = os.path.abspath(dlg.GetPath())
302 config_obj['path_set'] = True
301 config['evepath'][0] = os.path.abspath(dlg.GetPath())
302 config['path_set'] = True
303303
304 config.save()
304305 self.load_infowidgets()
305306
306307
307308 def update_motd(self):
308
309
310309 motdf = urllib.urlopen("http://eve-central.com/motd.txt")
311310 motd = ""
312311 for line in motdf.readlines():
  
2424import images
2525import urllib
2626
27from evec_upload.config import Config
2728
28
2929class OptionDialog(wx.Dialog):
3030 def __init__(self, parent):
31 config = Config()
3132
3233 wx.Dialog.__init__(self, parent, -1, "Options", style = wx.DEFAULT_DIALOG_STYLE)
3334
3939
4040
4141 self.backup = wx.CheckBox(self, -1, "Create CSV dumps the uploaded data")
42 self.backup.SetValue(config['backup'])
4243 sizer.Add(self.backup, 0, wx.ALL, 5)
4344
4445 self.suggest = wx.CheckBox(self, -1, "Offer suggestions of what can be uploaded")
4546 sizer.Add(self.suggest, 0, wx.ALL, 5)
4647
48 self.anon_cb = wx.CheckBox(self, -1, "Anonymous login - no username")
49 self.Bind(wx.EVT_CHECKBOX, self.OnAnonCb, self.anon_cb)
50 sizer.Add(self.anon_cb, 0, wx.ALL, 5)
4751
4852 line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL)
4953 sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5)
9898
9999 self.SetSizer(sizer)
100100 sizer.Fit(self)
101
102 char_name = config['character_name']
103
104 if char_name == "Anonymous":
105 self.anon_cb.SetValue(True)
106 self.uname.Enable(False)
107 self.passwd.Enable(False)
108 else:
109 self.uname.SetValue(char_name)
110
111
112 def OnAnonCb(self, evt):
113 if self.uname.IsEnabled():
114 self.uname.Enable(False)
115 else:
116 self.uname.Enable(True)
117 if self.passwd.IsEnabled():
118 self.passwd.Enable(False)
119 else:
120 self.passwd.Enable(True)
  
3333
3434from evec_upload.config import Config
3535
36
37ProgramVersion = 2000
38ProgramVersionNice = "2.0"
39CheckVersion = 1031
40
41#(UpdateUploadEvent, EVT_UPDATE_UPLOAD) = wx.lib.newevent.NewEvent()
42#(DoneUploadEvent, EVT_DONE_UPLOAD) = wx.lib.newevent.NewEvent()
43
4436def get_uploader(cfg, updcb):
4537 config = Config()
4638 upl = UploaderEC(identity=0, donecb=updcb)