Skip to content

Commit

Permalink
Files done. Working on GUI.
Browse files Browse the repository at this point in the history
  • Loading branch information
mintnick committed Jan 12, 2022
1 parent 21553c9 commit cc4c5d2
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 34 deletions.
25 changes: 25 additions & 0 deletions src/GUI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from tkinter import *
import os
from os.path import isfile

class GUI:
title = 'ESAM'
icon = 'images' + os.sep + 'icon.ico'
size = '800x800+400+400'

def __init__(self):
window = Tk()
window.title(self.title)
if isfile(self.icon):
window.iconbitmap(self.icon)
window.geometry(self.size)

# top buttons
serenity_btn = Button(text='国服',font=('bold', 25), command=())
serenity_btn.place(relx=0.2, rely=0.02, relwidth=0.15, height=50)
tranquility_btn = Button(text='欧服',font=('bold', 25), command=())
tranquility_btn.place(relx=0.65, rely=0.02, relwidth=0.15, height=50)

window.mainloop()

gui = GUI()
32 changes: 0 additions & 32 deletions src/SettingFilesReader.py

This file was deleted.

3 changes: 1 addition & 2 deletions src/EsiReader.py → src/esi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
class EsiReader:
prefix = ''
suffix = ''
err_msg = '未读取到角色名'

def __init__(self, server):
if server == 'Tranquility':
Expand All @@ -25,4 +24,4 @@ def getCharacterName(self, id):
name = json.loads(data.read().decode())['name']
return name
except urllib.error.HTTPError as e:
return err_msg
return ''
53 changes: 53 additions & 0 deletions src/files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import os
from os import listdir
from pathlib import Path
import esi
import time

class SettingFilesReader:
# Mac
root = '/Users/nick'
# root = Path.home().__str__() + '\AppData\Local\CCP\EVE\\'
server = ''
dirs = []
character = []

def __init__(self, server):
self.server = server
if server == 'Tranquility':
# self.dirs = [(root_path + f) for f in listdir(root_path) if f.endswith('eve_sharedcache_tq_tranquility')]
# Mac path, for dev purpose
self.dirs = [(self.root + f) for f in listdir(self.root) if f.endswith('EVESettings')]
elif server == 'Serenity':
self.dirs = [(self.root + f) for f in listdir(self.root) if f.endswith('eve_sharedcache_serenity_serenity.evepc.163.com')]
else:
print('Invalid server name')

def getDirs(self):
return self.dirs

def readCharacters(self, path):
char_prefix = 'core_char_'
user_prefix = 'core_user_'

characters = [] # [(id, name)]
users = [] # [(id, last_mod_time)]

# is directory exsits
directory = os.path.join(path, 'settings_Default')
if not os.path.isdir(directory):
return [], []

esiReader = esi.EsiReader(self.server)
for file in os.listdir(directory):
filename = os.fsdecode(file)
id = filename.split('.')[0].split('_')[-1]
if id.isnumeric():
if filename.startswith(char_prefix):
name = esiReader.getCharacterName(id)
characters.append((id, name))
elif filename.startswith(user_prefix):
mod_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(os.path.getmtime(directory + os.sep + file)))
users.append((id, mod_time))

return characters, users
Empty file added src/main.py
Empty file.

0 comments on commit cc4c5d2

Please sign in to comment.