p3lib 1.1.124__py2.py3-none-any.whl → 1.1.125__py2.py3-none-any.whl

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.
p3lib/helper.py CHANGED
@@ -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
@@ -451,3 +452,69 @@ def getProgramVersion():
451
452
  return -999.99
452
453
  return programVersion
453
454
 
455
+ def get_assets_folders():
456
+ """@return A list of all the assets folders found."""
457
+ searchFolders = []
458
+ assetsFolders = []
459
+ calling_file = None
460
+ # Get the full path to the python file that called this get_assets_folders() function.
461
+ frame = inspect.stack()[1]
462
+ module = inspect.getmodule(frame[0])
463
+ if module and hasattr(module, '__file__'):
464
+ calling_file = os.path.abspath(module.__file__)
465
+
466
+ if calling_file:
467
+ startup_path = os.path.dirname(calling_file)
468
+ searchFolders.append( os.path.join(startup_path, 'assets') )
469
+ pp1 = os.path.join(startup_path, '..')
470
+ searchFolders.append( os.path.join(pp1, 'assets') )
471
+ pp2 = os.path.join(pp1, '..')
472
+ searchFolders.append( os.path.join(pp2, 'assets') )
473
+ # Try all the site packages folders we know about.
474
+ for path in sys.path:
475
+ if 'site-packages' in path:
476
+ site_packages_path = path
477
+ searchFolders.append( os.path.join(site_packages_path, 'assets') )
478
+
479
+ for folder in searchFolders:
480
+ absPath = os.path.abspath(folder)
481
+ if os.path.isdir(absPath):
482
+ assetsFolders.append(absPath)
483
+
484
+ return assetsFolders
485
+
486
+ def get_assets_folder(raise_error=True):
487
+ """@brief Get the assets folder.
488
+ @param raise_error If True then raise an error if the assets folder is not found.
489
+ @return The abs assets folder path string."""
490
+ searchFolders = []
491
+ assetsFolder = None
492
+ calling_file = None
493
+ # Get the full path to the python file that called this get_assets_folder() function.
494
+ frame = inspect.stack()[1]
495
+ module = inspect.getmodule(frame[0])
496
+ if module and hasattr(module, '__file__'):
497
+ calling_file = os.path.abspath(module.__file__)
498
+
499
+ if calling_file:
500
+ startup_path = os.path.dirname(calling_file)
501
+ searchFolders.append( os.path.join(startup_path, 'assets') )
502
+ pp1 = os.path.join(startup_path, '..')
503
+ searchFolders.append( os.path.join(pp1, 'assets') )
504
+ pp2 = os.path.join(pp1, '..')
505
+ searchFolders.append( os.path.join(pp2, 'assets') )
506
+ # Try all the site packages folders we know about.
507
+ for path in sys.path:
508
+ if 'site-packages' in path:
509
+ site_packages_path = path
510
+ searchFolders.append( os.path.join(site_packages_path, 'assets') )
511
+
512
+ for folder in searchFolders:
513
+ absPath = os.path.abspath(folder)
514
+ if os.path.isdir(absPath):
515
+ assetsFolder = absPath
516
+
517
+ if raise_error and assetsFolder is None:
518
+ raise Exception('Failed to find assets folder.')
519
+
520
+ return assetsFolder
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: p3lib
3
- Version: 1.1.124
3
+ Version: 1.1.125
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
  License: MIT
6
6
  Author: Paul Austen
@@ -7,7 +7,7 @@ p3lib/conduit.py,sha256=jPkjdtyCx2I6SFqcEo8y2g7rgnZ-jNY7oCuYIETzT5Q,6046
7
7
  p3lib/database_if.py,sha256=XKu1w3zftGbj4Rh54wrWJnoCtqHkhCzJUPN2S70XIKg,11915
8
8
  p3lib/file_io.py,sha256=A7_GKYPlmjRjq6U1YuWhmB0OhLhNm6cWQfQX8qfgYTk,5041
9
9
  p3lib/gnome_desktop_app.py,sha256=zl9SKRBV8ipVg2faCs_gbAr8c42J1N_pntbFGG2BMiE,6694
10
- p3lib/helper.py,sha256=coGT0jv_hzfZJ46GLcADtdh5uhPtH8pxqIFVIG-nux4,15120
10
+ p3lib/helper.py,sha256=8gczHkqkvxoTKC2srf3t8s_0Psuun0iEO9xD-GBCH1Y,17802
11
11
  p3lib/json_networking.py,sha256=6u4s1SmypjTYPnSxHP712OgQ3ZJaxOqIkgHQ1J7Qews,9738
12
12
  p3lib/login.html,sha256=DADTJGuvWQ-LTO4X6SaFdqK7JMW03DAa3lRieGD0d6g,2748
13
13
  p3lib/mqtt_rpc.py,sha256=6LmFA1kR4HSJs9eWbOJORRHNY01L_lHWjvtE2fmY8P8,10511
@@ -19,7 +19,7 @@ p3lib/ssh.py,sha256=OyoAQ_h1L2RfkjTAChDrvLFfl4Fe_gBNdX5rvK-wKiw,42125
19
19
  p3lib/table_plot.py,sha256=RPncwVlGUkkx5Fw0dHQedXo0TSPlTi__VrJBDzaMsuI,32116
20
20
  p3lib/uio.py,sha256=Aaxc99XiE3d2f9vLjaN-bZsckoNxay5t0ujdK6PXGrw,23265
21
21
  p3lib/windows_app.py,sha256=cSkGDIakamxylhOYk0BHjjUQwBBhOq7sij4a7xs9v44,3057
22
- p3lib-1.1.124.dist-info/LICENSE,sha256=igqTy5u0kVWM1n-NUZMvAlinY6lVjAXKoag0okkS8V8,1067
23
- p3lib-1.1.124.dist-info/METADATA,sha256=Knk8TeQt5pqrzj9MMy4gZuaAedNsWBxZ29Mrwn01yhg,1382
24
- p3lib-1.1.124.dist-info/WHEEL,sha256=5druYqcII7zHXzX7qmN0TH895Jg3yuTtfjMgJIVBrKE,92
25
- p3lib-1.1.124.dist-info/RECORD,,
22
+ p3lib-1.1.125.dist-info/LICENSE,sha256=igqTy5u0kVWM1n-NUZMvAlinY6lVjAXKoag0okkS8V8,1067
23
+ p3lib-1.1.125.dist-info/METADATA,sha256=a6edrYmOrde-6Z9Obu5tzDMF825w5tOUEM1kMC6PSoI,1382
24
+ p3lib-1.1.125.dist-info/WHEEL,sha256=5druYqcII7zHXzX7qmN0TH895Jg3yuTtfjMgJIVBrKE,92
25
+ p3lib-1.1.125.dist-info/RECORD,,