Browse Source

Merged update_mtimes and build to update

Created config
master
Raphael Roberts 7 years ago
parent
commit
3f11191533
  1. 6
      config.ini
  2. 16
      config.py
  3. 2
      opener.py
  4. 2
      opts.py
  5. 12
      searcher.py
  6. 37
      update.py
  7. 13
      update_mtimes.py
  8. 3
      util.py

6
config.ini

@ -0,0 +1,6 @@
[global]
no_admin = yes
[exe]
; comma separated paths
paths= %userprofile%,%programfiles%,%programfiles(x86)%,

16
config.py

@ -0,0 +1,16 @@
import configparser
import re
import os.path as osp
# https://stackoverflow.com/a/11866695
CONFIG_PATH = osp.join(osp.dirname(__file__),'config.ini')
class MyParser(configparser.ConfigParser):
def __init__(self):
super().__init__(interpolation = configparser.ExtendedInterpolation())
def getlist(self,section, option,fallback=None):
data = self.get(section,option,fallback=fallback)
if data == fallback:
return data
return list(filter(bool,re.split(' *, *',data)))
config = MyParser()
config.read(CONFIG_PATH)
print(config.getlist('exe','paths'))

2
opener.py

@ -39,7 +39,7 @@ def standalone(path,params=[],windowless =False,cwd = None):
else:
subprocess.Popen([fullpath]+params,cwd=cwd)
def dependant(path,params=[],mode = 'execute'):
ext = get_ext(path)
if ext:

2
opts.py

@ -4,7 +4,7 @@ prefix = [
'help':'update the listings for ext',
'action':'store_true',
},
]
common = [
{

12
searcher.py

@ -1,11 +1,17 @@
import sqlite3
import os
import re
import update
# https://stackoverflow.com/a/5365533
osp = os.path
DB_PATH = osp.join(osp.dirname(__file__),'ext.db')
ext_database = sqlite3.connect(DB_PATH)
def init_db():
cur = ext_database.cursor()
cur.execute('CREATE TABLE "updates" ( `ext` TEXT, `update_time` INTEGER, `file_count` INTEGER, PRIMARY KEY(`ext`) )')
def regexp(expr, item):
return re.search(expr,item) is not None
ext_database.create_function("REGEXP", 2, regexp)
class Searcher:
def __init__(self,ext):
self.cur = ext_database.cursor()
@ -22,4 +28,8 @@ class Searcher:
def _commit_(self):
ext_database.commit()
def search(query,regex=False):
pass
if regex:
self.cur.execute('SELECT * FROM ? WHERE name REGEXP ?',[self.ext,query])
else:
self.cur.execute('SELECT * FROM ? WHERE name LIKE ?',[self.ext,query])
return self.cur.fetchall()

build.py → update.py

13
update_mtimes.py

@ -1,13 +0,0 @@
import ctypes
import os
def is_admin():
return ctypes.windll.shell32.IsUserAnAdmin() != 0
exe_path = os.path.expandvars(r"%userprofile%\portables"
r"\foldertimeupdate"
r"\FolderTimeUpdate.exe"
)
def update(*starts,force_admin = True):
if not is_admin() and force_admin:
raise Exception("Process must be admin")
for start in starts:
subprocess.check_call([exe_path,'/stext','null','/BaseFolder',start])

3
util.py

@ -1,7 +1,6 @@
from ctypes import windll
import os
#https://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-drive-letters-in-python
#u=RichieHindle
# https://stackoverflow.com/a/827397
def get_drives():
uppercase = map(chr,range(ord('A'),ord('A')+26))
drives = []

Loading…
Cancel
Save