lyrpy 0.0.2__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.
lyr/LUos.py ADDED
@@ -0,0 +1,797 @@
1
+ """LUos.py"""
2
+ # -*- coding: UTF-8 -*-
3
+ __annotations__ = """
4
+ =======================================================
5
+ Copyright (c) 2023-2024
6
+ Author:
7
+ Lisitsin Y.R.
8
+ Project:
9
+ LU_PY
10
+ Python (LU)
11
+ Module:
12
+ LUos.py
13
+
14
+ =======================================================
15
+ """
16
+ #------------------------------------------
17
+ # БИБЛИОТЕКИ python
18
+ #------------------------------------------
19
+ import os
20
+ import platform
21
+ import sys
22
+ import enum
23
+ import ctypes
24
+ import datetime
25
+ import logging
26
+
27
+ """
28
+ Кроссплатформенные функции:
29
+ Информации об архитектуре platform.architecture(),
30
+ Тип машины platform.machine(),
31
+ Сетевое имя компьютера platform.node(),
32
+ Сведения о базовой платформе platform.platform(),
33
+ Реальное имя процессора platform.processor(),
34
+ Номер и дата сборки Python platform.python_build(),
35
+ Версия компилятора platform.python_compiler(),
36
+ Ветвь SCM реализации Python platform.python_branch(),
37
+ Реализация Python platform.python_implementation(),
38
+ Ревизия SCM реализации Python platform.python_revision(),
39
+ Версия Python как строка platform.python_version(),
40
+ Версия Python как кортеж platform.python_version_tuple(),
41
+ Сведения о выпуске системы platform.release(),
42
+ Имя операционной системы platform.system(),
43
+ platform.system_alias(),
44
+ Версия выпуска системы platform.version(),
45
+ Сведения команды терминала uname platform.uname(),
46
+ Функции платформы Java:
47
+ Версия интерфейса для Jython platform.java_ver(),
48
+ Функции платформы Windows:
49
+ Информация о версии из реестра Windows platform.win32_ver(),
50
+ Текущая редакция Windows platform.win32_edition(),
51
+ True, если Windows, распознается как IoT platform.win32_is_iot(),
52
+ Функции платформы Mac OS:
53
+ Информация о версии Mac OS platform.mac_ver(),
54
+ Функции платформы Unix:
55
+ Версия библиотеки libc platform.libc_ver(),
56
+ Функции платформы Linux:
57
+ Идентификатор ОС из os-release platform.freedesktop_os_release() (доступна в Python 3.10).
58
+ """
59
+ #------------------------------------------
60
+ # БИБЛИОТЕКИ сторонние
61
+ #------------------------------------------
62
+ import psutil
63
+
64
+ # if platform.system() == 'Windows':
65
+ # import win32api
66
+ # import win32con
67
+ # #endif
68
+
69
+ #------------------------------------------
70
+ # БИБЛИОТЕКИ LU
71
+ #------------------------------------------
72
+ if platform.system() == 'Windows':
73
+ import lyr.LUParserREG as LUParserREG
74
+ #endif
75
+
76
+ import lyr.LUDateTime as LUDateTime
77
+
78
+ #Correspondence to tools in the os module
79
+ #-----------------------------------------------------------------------------
80
+ # os and os.path pathlib
81
+ # -----------------------------------------------------------------------------
82
+ # os.path.abspath() Path.absolute() [1]
83
+ # os.path.realpath() Path.resolve()
84
+ # os.chmod() Path.chmod()
85
+ # os.mkdir() Path.mkdir()
86
+ # os.makedirs() Path.mkdir()
87
+ # os.rename() Path.rename()
88
+ # os.replace() Path.replace()
89
+ # os.rmdir() Path.rmdir()
90
+ # os.remove(), os.unlink() Path.unlink()
91
+ # os.getcwd() Path.cwd()
92
+ # os.path.exists() Path.exists()
93
+ # os.path.expanduser() Path.expanduser() and Path.home()
94
+ # os.listdir() Path.iterdir()
95
+ # os.walk() Path.walk()
96
+ # os.path.isdir() Path.is_dir()
97
+ # os.path.isfile() Path.is_file()
98
+ # os.path.islink() Path.is_symlink()
99
+ # os.link() Path.hardlink_to()
100
+ # os.symlink() Path.symlink_to()
101
+ # os.readlink() Path.readlink()
102
+ # os.path.relpath() PurePath.relative_to() [2]
103
+ # os.stat() Path.stat(), Path.owner(), Path.group()
104
+ # os.path.isabs() PurePath.is_absolute()
105
+ # os.path.join() PurePath.joinpath()
106
+ # os.path.basename() PurePath.name
107
+ # os.path.dirname() PurePath.parent
108
+ # os.path.samefile() Path.samefile()
109
+ # os.path.splitext() PurePath.stem and PurePath.suffix
110
+
111
+
112
+ cHOME = 'HOME'
113
+ cWINDIR = 'windir'
114
+ cTEST = 'TEST'
115
+
116
+ @enum.unique
117
+ class TProductType(enum.Enum):
118
+ """TFoldersConst"""
119
+ W95 = 'Windows 95'
120
+ W98 = 'Windows 98'
121
+ WNT1 = 'Windows NT Workstation'
122
+ WNT2 = 'Windows NT Server'
123
+ WNT3 = 'Windows NT Domain Controller'
124
+ W20001 = 'Windows 2000 Professional'
125
+ W20002 = 'Windows 2000 Server'
126
+ W20003 = 'Windows 2000 Domain Controller'
127
+ WXP1 = 'Windows XP Home Edition'
128
+ WXP2 = 'Windows XP Home Edition Tablet PC'
129
+ WXP3 = 'Windows XP Professional'
130
+ WXP4 = 'Windows XP Professional Tablet PC'
131
+ W20031 = 'Windows Server 2003'
132
+ W20032 = 'Windows Server 2003 Domain Controller'
133
+ W7 = 'Windows 6.1 / 1'
134
+ W8 = 'Windows 6.2 / 1'
135
+ WXX = 'W95 or W98'
136
+ WXXXX = 'W2000 or WXP or W2003'
137
+ #endclass
138
+
139
+ cSection = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders'
140
+
141
+ class TFoldersConst(enum.Enum):
142
+ """TFoldersConst"""
143
+ cuDesktop = 'Desktop'
144
+ cuStartMenu = 'Start Menu'
145
+ cuFavorites = 'Favorites'
146
+ cuPrograms = 'Programs'
147
+ cuStartup = 'Startup'
148
+ cuMyDocuments = 'Personal'
149
+
150
+ lmDesktop = 'Desktop'
151
+ lmStartMenu = 'Start Menu'
152
+ lmFavorites = 'Favorites'
153
+ lmPrograms = 'Programs'
154
+ lmStartup = 'Startup'
155
+ #endclass
156
+
157
+ class TFolders (object):
158
+ """TFolders"""
159
+ luClassName = 'TFolders'
160
+ __annotations__ ="""
161
+ """
162
+ #--------------------------------------------------
163
+ # constructor
164
+ #--------------------------------------------------
165
+ def __init__ (self, **kwargs):
166
+ """ Constructor """
167
+ #beginfunction
168
+ super ().__init__ (**kwargs)
169
+ self.__FRegParser = LUParserREG.TREGParser()
170
+ ...
171
+ #endfunction
172
+
173
+ #--------------------------------------------------
174
+ # destructor
175
+ #--------------------------------------------------
176
+ def __del__ (self):
177
+ """ destructor """
178
+ #beginfunction
179
+ LClassName = self.__class__.__name__
180
+ s = '{} уничтожен'.format(LClassName)
181
+ # LULog.LoggerTOOLS_AddLevel (LULog.DEBUGTEXT, s)
182
+ #print (s)
183
+ #endfunction
184
+
185
+ #--------------------------------------------------
186
+ # @property cuDesktop
187
+ #--------------------------------------------------
188
+ # getter
189
+ @property
190
+ def cuDesktop(self):
191
+ #beginfunction
192
+ return self.GetFolderCU (TFoldersConst.cuDesktop.value)
193
+ #endfunction
194
+ # setter
195
+ @cuDesktop.setter
196
+ def cuDesktop (self, AValue: str):
197
+ #beginfunction
198
+ self.SetFolderCU (TFoldersConst.cuDesktop.value, AValue)
199
+ #endfunction
200
+
201
+ #--------------------------------------------------
202
+ # @property lmDesktop
203
+ #--------------------------------------------------
204
+ # getter
205
+ @property
206
+ def lmDesktop(self):
207
+ #beginfunction
208
+ return self.GetFolderCU (TFoldersConst.cuDesktop.value)
209
+ #endfunction
210
+ # setter
211
+ @lmDesktop.setter
212
+ def lmDesktop (self, AValue: str):
213
+ #beginfunction
214
+ self.SetFolderCU (TFoldersConst.cuDesktop.value, AValue)
215
+ #endfunction
216
+ #--------------------------------------------------
217
+ # @property cuStartMenu
218
+ #--------------------------------------------------
219
+ # getter
220
+ @property
221
+ def cuStartMenu(self):
222
+ #beginfunction
223
+ return self.GetFolderCU (TFoldersConst.cuStartMenu.value)
224
+ #endfunction
225
+ # setter
226
+ @cuStartMenu.setter
227
+ def cuStartMenu (self, AValue: str):
228
+ #beginfunction
229
+ self.SetFolderCU (TFoldersConst.cuStartMenu.value, AValue)
230
+ #endfunction
231
+
232
+ #--------------------------------------------------
233
+ # @property lmStartMenu
234
+ #--------------------------------------------------
235
+ # getter
236
+ @property
237
+ def lmStartMenu(self):
238
+ #beginfunction
239
+ return self.GetFolderCU (TFoldersConst.cuStartMenu.value)
240
+ #endfunction
241
+ # setter
242
+ @lmStartMenu.setter
243
+ def lmStartMenu (self, AValue: str):
244
+ #beginfunction
245
+ self.SetFolderCU (TFoldersConst.cuStartMenu.value, AValue)
246
+ #endfunction
247
+
248
+ #--------------------------------------------------
249
+ # @property cuFavorites
250
+ #--------------------------------------------------
251
+ # getter
252
+ @property
253
+ def cuFavorites(self):
254
+ #beginfunction
255
+ return self.GetFolderCU (TFoldersConst.cuFavorites.value)
256
+ #endfunction
257
+ # setter
258
+ @cuFavorites.setter
259
+ def cuFavorites (self, AValue: str):
260
+ #beginfunction
261
+ self.SetFolderCU (TFoldersConst.cuFavorites.value, AValue)
262
+ #endfunction
263
+
264
+ #--------------------------------------------------
265
+ # @property lmFavorites
266
+ #--------------------------------------------------
267
+ # getter
268
+ @property
269
+ def lmFavorites(self):
270
+ #beginfunction
271
+ return self.GetFolderCU (TFoldersConst.cuFavorites.value)
272
+ #endfunction
273
+ # setter
274
+ @lmFavorites.setter
275
+ def lmFavorites (self, AValue: str):
276
+ #beginfunction
277
+ self.SetFolderCU (TFoldersConst.cuFavorites.value, AValue)
278
+ #endfunction
279
+
280
+ #--------------------------------------------------
281
+ # @property cuPrograms
282
+ #--------------------------------------------------
283
+ # getter
284
+ @property
285
+ def cuPrograms(self):
286
+ #beginfunction
287
+ return self.GetFolderCU (TFoldersConst.cuPrograms.value)
288
+ #endfunction
289
+ # setter
290
+ @cuPrograms.setter
291
+ def cuPrograms (self, AValue: str):
292
+ #beginfunction
293
+ self.SetFolderCU (TFoldersConst.cuPrograms.value, AValue)
294
+ #endfunction
295
+
296
+ #--------------------------------------------------
297
+ # @property lmPrograms
298
+ #--------------------------------------------------
299
+ # getter
300
+ @property
301
+ def lmPrograms(self):
302
+ #beginfunction
303
+ return self.GetFolderCU (TFoldersConst.cuPrograms.value)
304
+ #endfunction
305
+ # setter
306
+ @lmPrograms.setter
307
+ def lmPrograms (self, AValue: str):
308
+ #beginfunction
309
+ self.SetFolderCU (TFoldersConst.cuPrograms.value, AValue)
310
+ #endfunction
311
+
312
+ #--------------------------------------------------
313
+ # @property cuStartup
314
+ #--------------------------------------------------
315
+ # getter
316
+ @property
317
+ def cuStartup(self):
318
+ #beginfunction
319
+ return self.GetFolderCU (TFoldersConst.cuStartup.value)
320
+ #endfunction
321
+ # setter
322
+ @cuStartup.setter
323
+ def cuStartup (self, AValue: str):
324
+ #beginfunction
325
+ self.SetFolderCU (TFoldersConst.cuStartup.value, AValue)
326
+ #endfunction
327
+
328
+ #--------------------------------------------------
329
+ # @property lmStartup
330
+ #--------------------------------------------------
331
+ # getter
332
+ @property
333
+ def lmStartup(self):
334
+ #beginfunction
335
+ return self.GetFolderCU (TFoldersConst.cuStartup.value)
336
+ #endfunction
337
+ # setter
338
+ @lmStartup.setter
339
+ def lmStartup (self, AValue: str):
340
+ #beginfunction
341
+ self.SetFolderCU (TFoldersConst.cuStartup.value, AValue)
342
+ #endfunction
343
+
344
+ #--------------------------------------------------
345
+ # @property cuMyDocuments
346
+ #--------------------------------------------------
347
+ # getter
348
+ @property
349
+ def cuMyDocuments(self):
350
+ #beginfunction
351
+ return self.GetFolderCU (TFoldersConst.cuMyDocuments.value)
352
+ #endfunction
353
+ # setter
354
+ @cuMyDocuments.setter
355
+ def cuMyDocuments (self, AValue: str):
356
+ #beginfunction
357
+ self.SetFolderCU (TFoldersConst.cuMyDocuments.value, AValue)
358
+ #endfunction
359
+
360
+ #--------------------------------------------------------------------------------
361
+ # GetFolderCU (AFolderName: str) -> str:
362
+ #--------------------------------------------------------------------------------
363
+ def GetFolderCU (self, AFolderName: str) -> str:
364
+ #beginfunction
365
+ LKeyName = AFolderName
366
+ LFolderValue, LType = self.__FRegParser.GetKeyReg (LUParserREG.THKEYConst.cHKCU, cSection, LKeyName)
367
+ return LFolderValue
368
+ #endfunction
369
+
370
+ #--------------------------------------------------------------------------------
371
+ # SetFolderCU (AFolderName: str, AValue: str)
372
+ #--------------------------------------------------------------------------------
373
+ def SetFolderCU (self, AFolderName: str, AValue: str):
374
+ #beginfunction
375
+ LKeyName = AFolderName
376
+ self.__FRegParser.SetValueReg (LUParserREG.THKEYConst.cHKCU, cSection,
377
+ LKeyName, LUParserREG.TValueTypes.vtEXPAND_SZ, AValue)
378
+ #endfunction
379
+
380
+ #--------------------------------------------------------------------------------
381
+ # GetFolderLM (AFolderName: str) -> str:
382
+ #--------------------------------------------------------------------------------
383
+ def GetFolderLM (self, AFolderName: str) -> str:
384
+ #beginfunction
385
+ LKeyName = AFolderName
386
+ LFolderValue, LType = self.__FRegParser.GetKeyReg(LUParserREG.THKEYConst.cHKLM, cSection, LKeyName)
387
+ return LFolderValue
388
+ #endfunction
389
+
390
+ #--------------------------------------------------------------------------------
391
+ # SetFolderLM (AFolderName: str, AValue: str)
392
+ #--------------------------------------------------------------------------------
393
+ def SetFolderLM (self, AFolderName: str, AValue: str):
394
+ #beginfunction
395
+ LKeyName = AFolderName
396
+ self.__FRegParser.SetValueReg (LUParserREG.THKEYConst.cHKLM, cSection,
397
+ LKeyName, LUParserREG.TValueTypes.vtEXPAND_SZ, AValue)
398
+ #endfunction
399
+ #endclass
400
+
401
+ class TOSInfo (object):
402
+ """TOSInfo"""
403
+ luClassName = 'TOSInfo'
404
+ __annotations__ ="""
405
+ """
406
+ #--------------------------------------------------
407
+ # constructor
408
+ #--------------------------------------------------
409
+ def __init__ (self, **kwargs):
410
+ """ Constructor """
411
+ #beginfunction
412
+ super ().__init__ (**kwargs)
413
+ ...
414
+ #endfunction
415
+
416
+ #--------------------------------------------------
417
+ # destructor
418
+ #--------------------------------------------------
419
+ def __del__ (self):
420
+ """ destructor """
421
+ #beginfunction
422
+ LClassName = self.__class__.__name__
423
+ s = '{} уничтожен'.format(LClassName)
424
+ #LUConst.LULogger.log (LULog.DEBUGTEXT, s)
425
+ #endfunction
426
+
427
+ # Return the number of CPUs in the system. Returns None if undetermined.
428
+ #--------------------------------------------------
429
+ # @property CPUs
430
+ #--------------------------------------------------
431
+ # getter
432
+ @property
433
+ def CPUs (self):
434
+ #beginfunction
435
+ return os.cpu_count()
436
+ #endfunction
437
+
438
+ # Returns the machine type
439
+ #--------------------------------------------------
440
+ # @property machine
441
+ #--------------------------------------------------
442
+ # getter
443
+ @property
444
+ def machine (self):
445
+ #beginfunction
446
+ return platform.machine()
447
+ #endfunction
448
+
449
+ # Returns the computer’s network name
450
+ #--------------------------------------------------
451
+ # @property node
452
+ #--------------------------------------------------
453
+ # getter
454
+ @property
455
+ def node (self):
456
+ #beginfunction
457
+ return platform.node()
458
+ #endfunction
459
+
460
+ # Returns a namedtuple() containing six attributes: system, node, release, version, machine, and processor
461
+ #--------------------------------------------------
462
+ # @property uname
463
+ #--------------------------------------------------
464
+ # getter
465
+ @property
466
+ def uname (self):
467
+ #beginfunction
468
+ return platform.uname ()
469
+ #endfunction
470
+
471
+ # Returns the (real) processor name, e.g. 'amdk6'.
472
+ #--------------------------------------------------
473
+ # @property processor
474
+ #--------------------------------------------------
475
+ # getter
476
+ @property
477
+ def processor (self):
478
+ #beginfunction
479
+ return platform.processor ()
480
+ #endfunction
481
+
482
+ # Returns the system’s release
483
+ #--------------------------------------------------
484
+ # @property release
485
+ #--------------------------------------------------
486
+ # getter
487
+ @property
488
+ def release (self):
489
+ #beginfunction
490
+ return platform.release ()
491
+ #endfunction
492
+
493
+ # Returns the system/OS name, such as 'Linux', 'Darwin', 'Java', 'Windows'
494
+ #--------------------------------------------------
495
+ # @property release
496
+ #--------------------------------------------------
497
+ # getter
498
+ @property
499
+ def system (self):
500
+ #beginfunction
501
+ return platform.system ()
502
+ #endfunction
503
+
504
+ # Returns the system’s release version
505
+ #--------------------------------------------------
506
+ # @property version
507
+ #--------------------------------------------------
508
+ # getter
509
+ @property
510
+ def version (self):
511
+ #beginfunction
512
+ return platform.version ()
513
+ #endfunction
514
+
515
+ #Returns (system, release, version) aliased to common marketing names
516
+ #platform.system_alias(system, release, version)
517
+
518
+ # Get additional version information from the Windows Registry and return a tuple (release, version, csd, ptype) referring to OS release
519
+ #--------------------------------------------------
520
+ # @property win32_ver
521
+ #--------------------------------------------------
522
+ # getter
523
+ @property
524
+ def win32_ver (self):
525
+ #beginfunction
526
+ return platform.win32_ver()
527
+ #endfunction
528
+
529
+ # Returns a string representing the current Windows edition, or None if the value cannot be determined. Possible values include but are not limited to 'Enterprise', 'IoTUAP', 'ServerStandard', and 'nanoserver'.
530
+ #--------------------------------------------------
531
+ # @property win32_edition
532
+ #--------------------------------------------------
533
+ @property
534
+ def win32_edition (self):
535
+ #beginfunction
536
+ return platform.win32_edition ()
537
+ #endfunction
538
+
539
+ #---------------------------------------------
540
+ # Python
541
+ #---------------------------------------------
542
+ # Returns a tuple (buildno, builddate) stating the Python build number and date as strings.
543
+ #--------------------------------------------------
544
+ # @property python_build
545
+ #--------------------------------------------------
546
+ @property
547
+ def python_build (self):
548
+ #beginfunction
549
+ return platform.python_build ()
550
+ #endfunction
551
+
552
+ # Returns a string identifying the compiler used for compiling Python.
553
+ #--------------------------------------------------
554
+ # @property python_compiler
555
+ #--------------------------------------------------
556
+ @property
557
+ def python_compiler (self):
558
+ #beginfunction
559
+ return platform.python_compiler ()
560
+ #endfunction
561
+
562
+ # Returns a string identifying the Python implementation SCM branch.
563
+ #--------------------------------------------------
564
+ # @property python_branch
565
+ #--------------------------------------------------
566
+ @property
567
+ def python_branch (self):
568
+ #beginfunction
569
+ return platform.python_branch ()
570
+ #endfunction
571
+
572
+ # Returns a string identifying the Python implementation
573
+ #--------------------------------------------------
574
+ # @property python_implementation
575
+ #--------------------------------------------------
576
+ @property
577
+ def python_implementation (self):
578
+ #beginfunction
579
+ return platform.python_implementation ()
580
+ #endfunction
581
+
582
+ # Returns a string identifying the Python implementation SCM revision.
583
+ #--------------------------------------------------
584
+ # @property python_revision
585
+ #--------------------------------------------------
586
+ @property
587
+ def python_revision (self):
588
+ #beginfunction
589
+ return platform.python_revision ()
590
+ #endfunction
591
+
592
+ # Returns the Python version
593
+ #--------------------------------------------------
594
+ # @property python_version
595
+ #--------------------------------------------------
596
+ @property
597
+ def python_version (self):
598
+ #beginfunction
599
+ return platform.python_version ()
600
+ #endfunction
601
+
602
+ # Python sys.version
603
+ #--------------------------------------------------
604
+ # @property version_sys
605
+ #--------------------------------------------------
606
+ @property
607
+ def version_sys (self):
608
+ #beginfunction
609
+ return sys.version
610
+ #endfunction
611
+
612
+ # Returns the Python version as tuple (major, minor, patchlevel) of strings.
613
+ #--------------------------------------------------
614
+ # @property python_version_tuple
615
+ #--------------------------------------------------
616
+ @property
617
+ def python_version_tuple (self):
618
+ #beginfunction
619
+ return platform.python_version_tuple ()
620
+ #endfunction
621
+
622
+ #--------------------------------------------------
623
+ # @property UserID
624
+ #--------------------------------------------------
625
+ @property
626
+ def UserID (self):
627
+ #beginfunction
628
+ return os.getlogin ()
629
+ #endfunction
630
+
631
+ @staticmethod
632
+ def Info_psutil ():
633
+ """Info_psutil"""
634
+ #beginfunction
635
+ """CPU"""
636
+ # Return system CPU times as a named tuple
637
+ psutil.cpu_times(percpu=False)
638
+ # Return the number of logical CPUs in the system
639
+ psutil.cpu_count (logical = True)
640
+
641
+ """Memory"""
642
+ # Return statistics about system memory usage as a named tuple including the following fields, expressed in bytes
643
+ psutil.virtual_memory ()
644
+
645
+ """Disks"""
646
+ # Return all mounted disk partitions as a list of named tuples including device, mount point and filesystem type
647
+ psutil.disk_partitions (all = False)
648
+ # Return disk usage statistics about the partition which contains the given path as a named tuple including total, used and free space
649
+ # psutil.disk_usage (path)
650
+
651
+ """Network"""
652
+ # Return the addresses associated to each NIC (network interface card) installed on the system as a dictionary whose keys are the NIC names and value is a list of named tuples for each address assigned to the NIC
653
+ psutil.net_if_addrs()
654
+
655
+ """Other system info"""
656
+ psutil.users ()
657
+
658
+ """Processes"""
659
+
660
+ """Windows services"""
661
+ #endfunction
662
+ #endclass
663
+
664
+ #------------------------------------------
665
+ # GetCurrentDir
666
+ #------------------------------------------
667
+ def GetCurrentDir () -> str:
668
+ """GetCurrentDir"""
669
+ #beginfunction
670
+ return os.getcwd ()
671
+ #endfunction
672
+
673
+ #------------------------------------------
674
+ # APPWorkDir
675
+ #------------------------------------------
676
+ def APPWorkDir () -> str:
677
+ """APPWorkDir"""
678
+ #beginfunction
679
+ return os.getcwd ()
680
+ #endfunction
681
+
682
+ #------------------------------------------
683
+ # GetEnvVar
684
+ #------------------------------------------
685
+ def GetEnvVar (AEnvVar: str) -> str:
686
+ """GetEnvVar"""
687
+ #beginfunction
688
+ s = ''
689
+ try:
690
+ s = os.environ [AEnvVar]
691
+ except:
692
+ ...
693
+ finally:
694
+ ...
695
+ return s
696
+ #endfunction
697
+
698
+ #------------------------------------------
699
+ # SetEnvVar
700
+ #------------------------------------------
701
+ def SetEnvVar (AEnvVar: str, AValue: str):
702
+ """SetEnvVar"""
703
+ #beginfunction
704
+ os.environ[AEnvVar] = AValue
705
+ #endfunction
706
+
707
+ #------------------------------------------
708
+ # get_data
709
+ #------------------------------------------
710
+ def get_data (EXTENDED_NAME_FORMAT: int):
711
+ #beginfunction
712
+ GetUserNameEx = ctypes.windll.secur32.GetUserNameExW
713
+ data = EXTENDED_NAME_FORMAT
714
+ size = ctypes.pointer (ctypes.c_ulong (0))
715
+ GetUserNameEx (data, None, size)
716
+ nameBuffer = ctypes.create_unicode_buffer (size.contents.value)
717
+ GetUserNameEx (data, nameBuffer, size)
718
+ return nameBuffer.value
719
+ #endfunction
720
+
721
+ #------------------------------------------
722
+ # get_display_name
723
+ #------------------------------------------
724
+ def get_display_name ():
725
+ #beginfunction
726
+ GetUserNameEx = ctypes.windll.secur32.GetUserNameExW
727
+ NameDisplay = 3
728
+ size = ctypes.pointer (ctypes.c_ulong (0))
729
+ GetUserNameEx (NameDisplay, None, size)
730
+ nameBuffer = ctypes.create_unicode_buffer (size.contents.value)
731
+ GetUserNameEx (NameDisplay, nameBuffer, size)
732
+ return nameBuffer.value
733
+ #endfunction
734
+
735
+ #------------------------------------------
736
+ # Print_get_data
737
+ #------------------------------------------
738
+ def Print_get_data ():
739
+ #beginfunction
740
+ print ("NameUnknown : ", get_data (0))
741
+ print ("NameFullyQualifiedDN : ", get_data (1))
742
+ print ("NameSamCompatible : ", get_data (2))
743
+ print ("NameDisplay : ", get_data (3))
744
+ print ("NameUniqueId : ", get_data (6))
745
+ print ("NameCanonical : ", get_data (7))
746
+ print ("NameUserPrincipal : ", get_data (8))
747
+ print ("NameCanonicalEx : ", get_data (9))
748
+ print ("NameServicePrincipal : ", get_data (10))
749
+ print ("NameDnsDomain : ", get_data (12))
750
+ #endfunction
751
+
752
+ #------------------------------------------------------
753
+ # PrintGeneralTitle
754
+ #------------------------------------------------------
755
+ def PrintGeneralTitle ():
756
+ #beginfunction
757
+ LTOSInfo = TOSInfo()
758
+ print ('===========================================')
759
+ print ('Текущее время = ' + LUDateTime.DateTimeStr (True, datetime.datetime.now(), LUDateTime.cFormatDateTimeLog05))
760
+ print ('UserID = ' + LTOSInfo.UserID)
761
+ # print ('FullName = ' + @FullName+' ('+@Comment+')')
762
+ print ('PCUser = ' + LTOSInfo.node)
763
+ print ('CPUs = ' + str(LTOSInfo.CPUs))
764
+ # print (LTOSInfo.uname)
765
+ # print ('CPU = ' + @CPU+' '+@MHz)
766
+ print ('HostName = ' + LTOSInfo.node)
767
+ print ('OS = ' + LTOSInfo.uname.system+' '+ '('+LTOSInfo.uname.version+')')
768
+ # print ('CompName = ' + @WKSTA)
769
+ # print ('===========================================')
770
+ # print ('DomainPC = ' + @Domain)
771
+ # print ('DomainUser = ' + @LDomain)
772
+ # print ('LServer = ' + @LServer)
773
+ print ('===========================================')
774
+ #endfunction
775
+
776
+ #------------------------------------------------------
777
+ # main
778
+ #------------------------------------------------------
779
+ def main ():
780
+ #beginfunction
781
+ # PrintGeneralTitle ()
782
+ # Print_get_data ()
783
+ # get_display_name ()
784
+ ...
785
+ #endfunction
786
+
787
+ GOSInfo = TOSInfo ()
788
+
789
+ #------------------------------------------
790
+ #
791
+ #------------------------------------------
792
+ #beginmodule
793
+ if __name__ == '__main__':
794
+ main()
795
+ #endif
796
+
797
+ #endmodule