p3lib 1.1.114__tar.gz → 1.1.116__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: p3lib
3
- Version: 1.1.114
3
+ Version: 1.1.116
4
4
  Summary: A group of python modules for networking, plotting data, config storage, automating boot scripts, ssh access and user input output.
5
5
  Home-page: https://github.com/pjaos/p3lib
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "p3lib"
3
- version = "1.1.114"
3
+ version = "1.1.116"
4
4
  description = "A group of python modules for networking, plotting data, config storage, automating boot scripts, ssh access and user input output."
5
5
  authors = ["Paul Austen <pjaos@gmail.com>"]
6
6
  license = "MIT License"
@@ -9,6 +9,7 @@ import platform
9
9
  import json
10
10
  import traceback
11
11
  import socket
12
+ import inspect
12
13
 
13
14
  def initArgs(parser, lastCmdLineArg=None, checkHostArg=True):
14
15
  """This method is responsible for
@@ -446,3 +447,70 @@ def getProgramVersion():
446
447
  raise Exception(f"Failed to extract program version from '{line}' line of {poetryConfigFile} file.")
447
448
  return programVersion
448
449
 
450
+ def get_assets_folders():
451
+ """@return A list of all the assets folders found."""
452
+ searchFolders = []
453
+ assetsFolders = []
454
+ calling_file = None
455
+ # Get the full path to the python file that called this get_assets_folders() function.
456
+ frame = inspect.stack()[1]
457
+ module = inspect.getmodule(frame[0])
458
+ if module and hasattr(module, '__file__'):
459
+ calling_file = os.path.abspath(module.__file__)
460
+
461
+ if calling_file:
462
+ startup_path = os.path.dirname(calling_file)
463
+ searchFolders.append( os.path.join(startup_path, 'assets') )
464
+ pp1 = os.path.join(startup_path, '..')
465
+ searchFolders.append( os.path.join(pp1, 'assets') )
466
+ pp2 = os.path.join(pp1, '..')
467
+ searchFolders.append( os.path.join(pp2, 'assets') )
468
+ # Try all the site packages folders we know about.
469
+ for path in sys.path:
470
+ if 'site-packages' in path:
471
+ site_packages_path = path
472
+ searchFolders.append( os.path.join(site_packages_path, 'assets') )
473
+
474
+ for folder in searchFolders:
475
+ absPath = os.path.abspath(folder)
476
+ if os.path.isdir(absPath):
477
+ assetsFolders.append(absPath)
478
+
479
+ return assetsFolders
480
+
481
+
482
+ def get_assets_folder(raise_error=True):
483
+ """@brief Get the assests folder.
484
+ @param raise_error If True then raise an error if the assets folder is not found.
485
+ @return The abs assets folder path string."""
486
+ searchFolders = []
487
+ assetsFolder = None
488
+ calling_file = None
489
+ # Get the full path to the python file that called this get_assets_folder() function.
490
+ frame = inspect.stack()[1]
491
+ module = inspect.getmodule(frame[0])
492
+ if module and hasattr(module, '__file__'):
493
+ calling_file = os.path.abspath(module.__file__)
494
+
495
+ if calling_file:
496
+ startup_path = os.path.dirname(calling_file)
497
+ searchFolders.append( os.path.join(startup_path, 'assets') )
498
+ pp1 = os.path.join(startup_path, '..')
499
+ searchFolders.append( os.path.join(pp1, 'assets') )
500
+ pp2 = os.path.join(pp1, '..')
501
+ searchFolders.append( os.path.join(pp2, 'assets') )
502
+ # Try all the site packages folders we know about.
503
+ for path in sys.path:
504
+ if 'site-packages' in path:
505
+ site_packages_path = path
506
+ searchFolders.append( os.path.join(site_packages_path, 'assets') )
507
+
508
+ for folder in searchFolders:
509
+ absPath = os.path.abspath(folder)
510
+ if os.path.isdir(absPath):
511
+ assetsFolder = absPath
512
+
513
+ if raise_error and assetsFolder is None:
514
+ raise Exception('Failed to find assets folder.')
515
+
516
+ return assetsFolder
@@ -13,6 +13,8 @@ from time import sleep
13
13
  from queue import Queue
14
14
  from time import time, strftime, localtime
15
15
 
16
+ from p3lib.helper import getProgramVersion
17
+
16
18
  from nicegui import ui
17
19
 
18
20
  class TabbedNiceGui(object):
@@ -78,29 +80,7 @@ class TabbedNiceGui(object):
78
80
  def GetProgramVersion():
79
81
  """@brief Get the program version from the poetry pyproject.toml file.
80
82
  @return The version of the installed program (string value)."""
81
- poetryConfigFile = os.path.join(TabbedNiceGui.LOCAL_PATH, TabbedNiceGui.POETRY_CONFIG_FILE)
82
- if not os.path.isfile(poetryConfigFile):
83
- poetryConfigFile = os.path.join(TabbedNiceGui.LOCAL_PATH, ".." + os.sep + TabbedNiceGui.POETRY_CONFIG_FILE)
84
- poetryConfigFile2 = poetryConfigFile
85
- if not os.path.isfile(poetryConfigFile):
86
- cwd = os.getcwd()
87
- poetryConfigFile = os.path.join(cwd, TabbedNiceGui.POETRY_CONFIG_FILE)
88
- if not os.path.isfile(poetryConfigFile):
89
- raise Exception(f"{poetryConfigFile}, {poetryConfigFile2} and {poetryConfigFile} not found.")
90
-
91
- programVersion = None
92
- with open(poetryConfigFile, 'r') as fd:
93
- lines = fd.readlines()
94
- for line in lines:
95
- line=line.strip("\r\n")
96
- if line.startswith('version'):
97
- elems = line.split("=")
98
- if len(elems) == 2:
99
- programVersion = elems[1].strip('" ')
100
- break
101
- if programVersion is None:
102
- raise Exception(f"Failed to extract program version from '{line}' line of {poetryConfigFile} file.")
103
- return programVersion
83
+ return getProgramVersion()
104
84
 
105
85
  def __init__(self, debugEnabled, logPath=None):
106
86
  """@brief Constructor
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes