Skip to content

Commit

Permalink
Fix database folder checking
Browse files Browse the repository at this point in the history
  • Loading branch information
wgergely committed Oct 5, 2022
1 parent 60f9057 commit 7c9e4c9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
30 changes: 14 additions & 16 deletions bookmarks/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,11 @@ def __init__(self, server, job, root, parent=None):
self._is_valid = False
self._connection = None

self._server = server
self._job = job
self._root = root
self.server = server
self.job = job
self.root = root

self._bookmark = '/'.join((server, job, root))
self._bookmark = f'{server}/{job}/{root}'
self._bookmark_root = f'{self._bookmark}/{common.bookmark_cache_dir}'
self._database_path = f'{self._bookmark_root}/{common.bookmark_database}'

Expand Down Expand Up @@ -568,8 +568,12 @@ def _create_bookmark_dir(self):
can't create the folder.
"""
_cache_dir = QtCore.QDir(self.root())
_thumb_dir = QtCore.QDir(f'{self.root()}/thumbnails')
_root_dir = QtCore.QDir(self._bookmark)
if not _root_dir.exists():
return False

_cache_dir = QtCore.QDir(self._bookmark_root)
_thumb_dir = QtCore.QDir(f'{self._bookmark_root}/thumbnails')
if not _cache_dir.exists():
if not _cache_dir.mkpath('.'):
log.error(f'Could not create {_cache_dir.path()}')
Expand Down Expand Up @@ -632,9 +636,9 @@ def _add_info(self):
)
).format(
id=common.get_hash(self._bookmark),
server=b64encode(self._server),
job=b64encode(self._job),
root=b64encode(self._root),
server=b64encode(self.server),
job=b64encode(self.job),
root=b64encode(self.root),
user=b64encode(common.get_username()),
host=b64encode(platform.node()),
created=time.time(),
Expand Down Expand Up @@ -666,12 +670,6 @@ def _init_tables(self):
raise
sleep()

def root(self):
"""Returns the `root` path.
"""
return self._bookmark_root

def is_valid(self):
"""Returns the database's status.
Expand Down Expand Up @@ -712,7 +710,7 @@ def source(self, *args):
"""
if args:
return self._bookmark + '/' + '/'.join(args)
return f'{self._bookmark}/{"/".join(args)}'
return self._bookmark

def get_row(self, source, table):
Expand Down
2 changes: 0 additions & 2 deletions bookmarks/test/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import bookmarks.test.test_settings
import bookmarks.test.test_session_lock
import bookmarks.test.test_actions
import bookmarks.test.test_bookmarker

if __name__ == '__main__':
loader = unittest.TestLoader()
Expand All @@ -26,7 +25,6 @@
loader.loadTestsFromTestCase(bookmarks.test.test_settings.Test),
loader.loadTestsFromTestCase(bookmarks.test.test_actions.Test),
loader.loadTestsFromTestCase(bookmarks.test.test_actions.TestWidgetActions),
loader.loadTestsFromTestCase(bookmarks.test.test_bookmarker.Test),
)
suite = unittest.TestSuite(cases)
unittest.TextTestRunner(verbosity=2, failfast=True).run(suite)
28 changes: 16 additions & 12 deletions set_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,25 @@

pkg_root = QtCore.QFileInfo(f'{__file__}{os.path.sep}..').absoluteFilePath()


STRINGS = {
f'{pkg_root}/docs/source/conf.py': re.compile(r"release = \'([0-9]\.[0-9]\.[0-9])\'", flags=re.MULTILINE),
f'{pkg_root}/bookmarks/__init__.py': re.compile(r"Version-v([0-9]\.[0-9]\.[0-9])", flags=re.MULTILINE),
f'{pkg_root}/bookmarks/__init__.py': re.compile(r"__version__ = \'([0-9]\.[0-9]\.[0-9])\'", flags=re.MULTILINE),
f'{pkg_root}/README.md': re.compile(r"Version-v([0-9]\.[0-9]\.[0-9])", flags=re.MULTILINE),
f'{pkg_root}/bookmarks/maya/plugin.py': re.compile(r"__version__ = \'([0-9]\.[0-9]\.[0-9])\'", flags=re.MULTILINE),
f'{pkg_root}/installer/installer.iss': re.compile(r'#define MyAppVersion "([0-9]\.[0-9]\.[0-9])"', flags=re.MULTILINE),
f'{pkg_root}/launcher/CMakeLists.txt': re.compile(r'VERSION ([0-9]\.[0-9]\.[0-9])', flags=re.MULTILINE),
f'{pkg_root}/docs/source/guide.rst': re.compile(r'.*([0-9]\.[0-9]\.[0-9]).*', flags=re.MULTILINE),
f'{pkg_root}/docs/source/conf.py': re.compile(r"release = \'([0-9]\.[0-9]\.[0-9])\'",
flags=re.MULTILINE),
f'{pkg_root}/bookmarks/__init__.py': re.compile(r"Version-v([0-9]\.[0-9]\.[0-9])",
flags=re.MULTILINE),
f'{pkg_root}/bookmarks/__init__.py': re.compile(
r"__version__ = \'([0-9]\.[0-9]\.[0-9])\'", flags=re.MULTILINE),
f'{pkg_root}/README.md': re.compile(r"Version-v([0-9]\.[0-9]\.[0-9])",
flags=re.MULTILINE),
f'{pkg_root}/bookmarks/maya/plugin.py': re.compile(
r"__version__ = \'([0-9]\.[0-9]\.[0-9])\'", flags=re.MULTILINE),
f'{pkg_root}/installer/installer.iss': re.compile(
r'#define MyAppVersion "([0-9]\.[0-9]\.[0-9])"', flags=re.MULTILINE),
f'{pkg_root}/launcher/CMakeLists.txt': re.compile(r'VERSION ([0-9]\.[0-9]\.[0-9])',
flags=re.MULTILINE),
f'{pkg_root}/docs/source/guide.rst': re.compile(r'.*([0-9]\.[0-9]\.[0-9]).*',
flags=re.MULTILINE),
}


app = QtWidgets.QApplication()
version, res = QtWidgets.QInputDialog.getText(None, 'Enter Version', 'New Version')

Expand All @@ -27,7 +33,6 @@
if not version:
raise RuntimeError('Must enter a valid version')


for k, v in STRINGS.items():
if not os.path.isfile(k):
raise RuntimeError(f'{k} does not exist.')
Expand All @@ -41,4 +46,3 @@

with open(k, 'w', encoding='utf-8') as f:
f.write(v)

0 comments on commit 7c9e4c9

Please sign in to comment.