mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Use appdirs to manage file paths
This commit is contained in:
parent
7fa3142d71
commit
2ea5a6e639
@ -7,6 +7,7 @@ import pango
|
|||||||
import serial
|
import serial
|
||||||
import usb.core
|
import usb.core
|
||||||
import usb.util
|
import usb.util
|
||||||
|
import appdirs
|
||||||
import sys, os, os.path
|
import sys, os, os.path
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from os.path import expanduser
|
from os.path import expanduser
|
||||||
@ -20,11 +21,12 @@ except ImportError:
|
|||||||
# 2.x name
|
# 2.x name
|
||||||
configparser = __import__("ConfigParser")
|
configparser = __import__("ConfigParser")
|
||||||
|
|
||||||
IDE_PATH = os.path.dirname(os.path.realpath(__file__))
|
IDE_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||||
GLADE_PATH = IDE_PATH+"/openmv-ide.glade"
|
CFG_DIR = appdirs.user_config_dir(appname="OpenMV")
|
||||||
CONFIG_PATH = IDE_PATH+"/openmv.config"
|
GLADE_PATH = os.path.join(IDE_DIR, "openmv-ide.glade")
|
||||||
EXAMPLE_PATH = IDE_PATH+"/examples"
|
CONFIG_PATH = os.path.join(CFG_DIR, "openmv.config")
|
||||||
SCRIPTS_PATH = IDE_PATH+"/scripts"
|
EXAMPLE_PATH = os.path.join(IDE_DIR, "examples")
|
||||||
|
SCRIPTS_PATH = os.path.join(IDE_DIR, "scripts")
|
||||||
|
|
||||||
SCALE =1
|
SCALE =1
|
||||||
RECENT_FILES_LIMIT=5
|
RECENT_FILES_LIMIT=5
|
||||||
@ -135,6 +137,9 @@ class OMVGtk:
|
|||||||
self.builder.connect_signals(signals)
|
self.builder.connect_signals(signals)
|
||||||
|
|
||||||
# create fresh config if needed
|
# create fresh config if needed
|
||||||
|
if not os.path.isdir(CFG_DIR):
|
||||||
|
os.makedirs(CFG_DIR)
|
||||||
|
|
||||||
if not os.path.isfile(CONFIG_PATH):
|
if not os.path.isfile(CONFIG_PATH):
|
||||||
try:
|
try:
|
||||||
with open(CONFIG_PATH, "w") as f:
|
with open(CONFIG_PATH, "w") as f:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user