-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand-tube.py
More file actions
8755 lines (7817 loc) · 386 KB
/
command-tube.py
File metadata and controls
8755 lines (7817 loc) · 386 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
#!/usr/bin/python
# ----------------------------------------------------------------
# Command Tube - A tool can run local and server commands together
# GitHub: https://github.com/michael-hll/command-tube.git
# Author: Michael Han
# Email: michael_hll@outlook.com
# Copyright: @ 2021~2022
# ----------------------------------------------------------------
'''
<< About >>
Command Tube is a tool that can run a group of sequenced commands.
You can get a full list of supportted tube commands from readme document.
'''
import os
import sys
from os import path
from pathlib import Path
import traceback
import subprocess
from datetime import datetime, timedelta, date
import time
import argparse
from argparse import ArgumentParser
import re
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import xml.etree.ElementTree as ET
import math
from shutil import copyfile
import multiprocessing
from argparse import RawTextHelpFormatter
import uuid
import shlex
import shutil
from random import choice, randrange, paretovariate
import threading
import glob
import keyword
import json
# -------- CLASSES --------------
class Storage():
I = None
def __init__(self) -> None:
Storage.I = self
# -------- CONSTANTS START --------
self.C_CURR_VERSION = '2.0.8'
self.C_KEYWORDS = set(keyword.kwlist)
self.C_SUPPORT_FROM_VERSION = 'SUPPORT_FROM_VERSION'
self.C_YAML_VERSION = 'VERSION'
self.C_DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'
self.C_CURR_DIR = os.getcwd()
self.C_TUBE_HOME = 'TUBE_HOME'
self.C_OS_NAME = 'OS_NAME'
self.C_SLEEP_SECONDS = 1
self.C_BUILD_SUCCESSFUL = 'BUILD SUCCESSFUL'
self.C_BUILD_FAILED = 'BUILD FAILED'
self.C_TUBE_SUCCESSFUL = 'SUCCESSFUL'
self.C_TUBE_PARTIAL_SUCCESSFUL = 'PARTIAL SUCCESSFUL'
self.C_TUBE_FAILED = 'FAILED'
self.C_STATUS_LINE = '------------------'
self.C_SUCCESSFUL = 'SUCCESSFUL'
self.C_FAILED = 'FAILED'
self.C_SKIPPED = 'SKIPPED'
self.C_RUNNING = 'RUNNING'
# Tube Command names and parameters
self.C_LINUX_COMMAND = 'LINUX_COMMAND'
self.C_PATH = 'PATH'
self.C_COMMAND = 'COMMAND'
self.C_GET_XML_TAG_TEXT = 'GET_XML_TAG_TEXT'
self.C_SET_XML_TAG_TEXT = 'SET_XML_TAG_TEXT'
self.C_SET_FILE_KEY_VALUE = 'SET_FILE_KEY_VALUE'
self.C_WRITE_LINE_IN_FILE = 'WRITE_LINE_IN_FILE'
self.C_NEW_LINE_BEFORE = 'NEW_LINE_BEFORE'
self.C_NEW_LINE_BEFORE_SHORT = 'NLB'
self.C_NEW_LINE_AFTER = 'NEW_LINE_AFTER'
self.C_NEW_LINE_AFTER_SHORT = 'NLA'
self.C_DELETE_LINE = 'DELETE_LINE'
self.C_DELETE_LINE_SHORT = 'DL'
self.C_DELETE_LINE_IN_FILE = 'DELETE_LINE_IN_FILE'
self.C_LINE_BEGINS = 'LINE_BEGINS'
self.C_PAUSE = 'PAUSE'
self.C_TAIL_FILE = 'TAIL_FILE'
self.C_REPORT_PROGRESS = 'REPORT_PROGRESS'
self.C_GET_FILE_KEY_VALUE = 'GET_FILE_KEY_VALUE'
self.C_EMAIL = 'EMAIL'
self.C_EXEC = 'EXEC'
self.C_COUNT = 'COUNT'
self.C_SET_VARIABLE = 'SET_VARIABLE'
self.C_SET_TUBE = 'SET_TUBE'
self.C_DELETE_VARIABLE = 'DELETE_VARIABLE'
self.C_SFTP_GET = 'SFTP_GET'
self.C_SFTP_PUT = 'SFTP_PUT'
self.C_CHECK_CHAR_EXISTS = 'CHECK_CHAR_EXISTS'
self.C_REPLACE_CHAR = 'REPLACE_CHAR'
self.C_PRINT_VARIABLES = 'PRINT_VARIABLES'
self.C_PRINT = 'PRINT'
self.C_RUN_TUBE = 'RUN_TUBE'
self.C_BREAK = 'BREAK'
self.C_CONTINUE = 'CONTINUE'
self.C_CREATE_OJBECT = 'CREATE_OBJECT'
self.C_READ_LINE_IN_FILE = 'READ_LINE_IN_FILE'
self.C_LIST_FILES = 'LIST_FILES'
self.C_LIST_DIRS = 'LIST_DIRS'
self.C_FILE_EXIST = 'FILE_EXIST'
self.C_FILE_POP = 'FILE_POP'
self.C_FILE_APPEND = 'FILE_APPEND'
self.C_FILE_PUSH = 'FILE_PUSH'
self.C_FILE_EMPTY = 'FILE_EMPTY'
self.C_FILE_READ = 'FILE_READ'
self.C_FILE_DELETE = 'FILE_DELETE'
self.C_FILE_COPY = 'FILE_COPY'
self.C_FILE_MOVE = 'FILE_MOVE'
self.C_FILE_CREATE = 'FILE_CREATE'
self.C_FILE_INSERT = 'FILE_INSERT'
self.C_FILE_SORT = 'FILE_SORT'
self.C_FILE_DOWNLOAD = 'FILE_DOWNLOAD'
self.C_DIR_EXIST = 'DIR_EXIST'
self.C_DIR_DELETE = 'DIR_DELETE'
self.C_DIR_CREATE = 'DIR_CREATE'
self.C_TAIL_LINES_HEADER = 'TAIL '
self.C_REQUESTS_GET = 'REQUESTS_GET'
self.C_REQUESTS_POST = 'REQUESTS_POST'
self.C_REQUESTS_OPTIONS = 'REQUESTS_OPTIONS'
self.C_REQUESTS_PUT = 'REQUESTS_PUT'
self.C_REQUESTS_HEAD = 'REQUESTS_HEAD'
self.C_REQUESTS_PATCH = 'REQUESTS_PATCH'
self.C_REQUESTS_DELETE = 'REQUESTS_DELETE'
self.C_IMPORT_MODULE = 'IMPORT_MODULE'
# method – method for the new Request object: GET, OPTIONS, HEAD, POST, PUT, PATCH, or DELETE.
self.C_LOG_HEADER = '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\nCommand Tube Log starts at '
self.C_JOB_HEADER = '\n--------------------------------------\nJob starts at '
self.C_FINISHED_HEADER = '*** Command Tube Finished Status ***'
self.C_CONTINUE_PARAMETER = '--continue'
self.C_REDO_PARAMETER = '--redo'
self.C_IF_PARAMETER = '--if'
self.C_KEY_PARAMETER = '--key'
self.C_NOTES_PARAMETER = '--note'
self.C_PLACE_HOLDER = '--raw'
self.C_RAW_LOG = '--raw-log'
self.C_INDENTATION = ' '
self.C_RETRIED_COMMAND_NOTE = '* The star(*) after command type means the command is run again.'
self.C_FAILED_COMMAND_LIST = '----- Failed Command List -----'
self.C_DESC_NEW_LINE_SPACE = ' '
self.C_ALIAS = 'ALIAS'
self.C_HELP = '''Use optional 'args' argument you can set the tube file name or get tube help.
Input 'tube-yaml-file' to override the --tube argument value.
Input 'help commands [name]' to print all commands usages; With optional 'name' argument will only list command names.
Input 'help command-name [name|desc|syntax|parameters|support]' to print all the tube commands which name matched.
Input 'help general-arg-name' to print the general argument usage:
'help continue' to view the --continue syntax;
'help redo' to view the --redo syntax;
'help if' to view the --if syntax;
'help key' to view the --key syntax;
'help raw' to view the --raw syntax;
'help raw-log' to view the --raw-log syntax;
'help note' to view the --note syntax;
Input 'help template' to view the tube tempalte;
Input 'help variable' to view the tube variables usage;
Input 'help vars' to print all the given tube variables;'''
# Server used
self.C_SERVERS = 'SERVERS'
self.C_SERVER = 'SERVER'
self.C_SERVER_NAME = 'NAME'
self.C_SERVER_HOST = 'HOST'
self.C_SERVER_PORT = 'SSH_PORT'
self.C_SERVER_USER = 'USER'
self.C_SERVER_PASSWORD = 'PASSWORD'
self.C_SERVER_ROOT = 'ROOT'
self.C_SERVER_PROFILE = 'PROFILE'
self.C_CONNECT = 'CONNECT'
self.C_SSH_CONNECT_TIMEOUT = 15 # seconds
# Variables
self.C_VARIABLES = 'VARIABLES'
# Tube Argument Used
self.C_ARG_SYNTAX = 'SYNTAX'
self.C_ARG_ARGS = 'ARGS'
self.C_COMMAND_DESCRIPTION = 'DESCRIPTION'
# Run mode used
self.C_RUN_MODE = 'RUN_MODE'
self.C_RUN_MODE_SRC = 'SRC'
self.C_RUN_MODE_BIN = 'BIN'
self.C_RUN_MODE_DEBUG = 'DEBUG'
# Current Version
self.C_PROGRAM_NAME = 'Command Tube'
# Tube
self.C_TUBE = 'TUBE'
# Email
self.C_EMAIL = 'EMAIL'
self.C_EMAIL_SMTP_SERVER = 'EMAIL_SMTP_SERVER'
self.C_EMAIL_SERVER_PORT = 'EMAIL_SERVER_PORT'
self.C_EMAIL_SENDER_ADDRESS = 'EMAIL_SENDER_ADDRESS'
self.C_EMAIL_SENDER_PASSWORD = 'EMAIL_SENDER_PASSWORD'
self.C_EMAIL_RECEIVER_ADDRESS = 'EMAIL_RECEIVER_ADDRESS'
self.C_EMAIL_SUBJECT = 'EMAIL_SUBJECT'
# PRINT
self.C_PRINT_PREFIX = '[TUBE]'
self.C_PRINT_PREFIX_EMPTY = ''
self.C_PRINT_TYPE_INFO = 'INFO'
self.C_PRINT_TYPE_WARNING = 'WARNING'
self.C_PRINT_TYPE_ERROR = 'ERROR'
self.C_PRINT_TYPE_DEBUG = 'DEBUG'
self.C_PRINT_TYPE_EMPTY = ''
self.C_PRINT_COLOR_RED = (0,0,0)
self.C_PRINT_COLOR_YELLOW = (0,0,0)
self.C_PRINT_COLOR_ORANGE = (0,0,0)
self.C_PRINT_COLOR_GREEN = (0,0,0)
self.C_PRINT_COLOR_BLUE = (0,0,0)
self.C_PRINT_COLOR_PURPLE = (0,0,0)
self.C_PRINT_COLOR_GREY = (71,71,71)
self.C_PRINT_COLOR_STYLE = None
# -------- CONSTANTS END --------
# ************************************************************************
# Run mode
self.RUN_MODE = self.C_RUN_MODE_SRC
self.YAML_VERSION = None
# User inputs, these values should be all set well from config file
self.EXEC_DATE_TIME = '01/01/20 00:00:00'
self.GOTO_HOST_ROOT = 'cd /'
# Some default input parameters
self.IS_IMMEDIATE = False
self.IS_FORCE_RUN = False
self.IS_SENT_EMAIL = False
self.IS_DISABLE_LOG = False
self.SERVERS = None
self.VARIABLES = None
self.TUBE_NAME = None # Main tube name
self.TUBE_YAML = None
self.TUBE_YAML_FILE = None
self.TUBE_LOG_FILE = 'tube.log'
self.IS_CLEAR_LOG = False
self.IS_LOOP = False
self.LOOP_TIMES = 1024
self.CURR_LOOP_ID = 0
self.NEXT_REFRESH = 0
self.PIP_NAME = 'pip'
# Email configuration
self.EMAIL_SMTP_SERVER = 'smtp.live.com'
self.EMAIL_SERVER_PORT = 587
self.EMAIL_SENDER_ADDRESS = '<sender email address>'
self.EMAIL_SENDER_PASSWORD = '<sender email password>'
self.EMAIL_RECEIVER_ADDRESS = '<receiver email address comma list>'
self.EMAIL_SUBJECT = 'Command Tube Result'
# global variables
self.LOGS = []
self.DISK_SPACE_STATUS = {}
self.INSTALLED_PACKAGES = []
self.TUBE = None # Reference to the main tube instance
self.TUBE_RUN = [] # Reference the main tube tube run list
self.TUBE_LIST = [] # Hold all the instanced tube list
self.HOSTS = {}
self.CURR_HOST = ''
self.CURR_HOST_PROFILE = ''
self.CURR_HOST_ROOT = ''
self.START_DATE_TIME = ''
self.IS_STOP = False
self.MAX_TUBE_COMMAND_LENGTH = 10
self.TUBE_FILE_LIST = {}
self.IS_MATRIX_MODE = False
self.IS_MATRIX_MODE_RUNNING = False
self.MATRIX_THREAD = None
self.IS_REPORT_PROGRESS = False
self.HAS_EMAIL_SETTINGS = False
self.EVAL_CODE_SET = set()
self.__gen_tube_args()
self.__add_additional_keywords()
def __gen_tube_args(self):
# Tube Command argument configurations design details
# 0: Is postion arguments
# 1: - Short argument name. eg: -f (if you want leave it empty, then only put '-' value)
# 2: -- Long argument anme. eg: --force
# 3: type
# 4: nargs
# 5: destination
# 6: is required
# 7: has action
# 8: action
# 9: default
# 10: choices
# LAST: description
self.TUBE_ARGS_CONFIG = {
self.C_RUN_TUBE: {
self.C_SUPPORT_FROM_VERSION: '2.0.2',
self.C_ALIAS: {'RUN'},
self.C_ARG_ARGS: [
[True, '-','--', 'str', '+', 'tube', True, False, '', '',
'The tube you want to run. It supports 3 formats: \
\n{0} - \'file.yaml\': Run TUBE from file.yaml file. With this format the global variables in file.xml will also be imported. \
\n{0} - \'file[X]\': Run tube X from file.yaml file. \
\n{0} - \'X\': Run tube X from the current yaml file.'.format(Storage.I.C_DESC_NEW_LINE_SPACE)],
[False, '-v','--variables', 'str', '+', 'variables', False, False, '', '',
'Pass local variable key values to sub tube. format: -v v1 = 1, v2 = \'Command Tube\''],
[False, '-w','--while', 'str', '+', 'conditions', False, False, '', '',
'Set the while condtions to run the tube: --while <eval-expression-condition>'],
[False, '-e','--each', 'str', '+', 'each', False, False, '', '',
'Set the foreach loop arguments with format: --each [index_name,] item_name in list_name'],
[False, '-f','--for', 'str', '+', 'each', False, False, '', '',
'The alias of --each argument.'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Run a sub-tube. \n{0:13s}With the \'--while\' conditions provided, {1} will continuely run and stop when conditions return false. \
\n{0:13s}With the \'--each\' parameters provided, {1} will iterate the list variable and run the sub-tube.' \
.format(' ', self.C_RUN_TUBE)
},
self.C_BREAK: {
self.C_SUPPORT_FROM_VERSION: '2.0.2',
self.C_ALIAS: {'BREAK'},
self.C_ARG_ARGS: [
[True, '-','--', 'str', '*', 'reason', False, False, '', '',
'The reason you want to break. [Optional]'],
],
self.C_CONTINUE_PARAMETER: False,
self.C_REDO_PARAMETER: False,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'The command can break a tube\'s running.'
},
self.C_CONTINUE: {
self.C_SUPPORT_FROM_VERSION: '2.0.2',
self.C_ALIAS: {'CONTINUE'},
self.C_ARG_ARGS: [
[True, '-','--', 'str', '*', 'reason', False, False, '', '',
'The reason you want to continue. [Optional]'],
],
self.C_CONTINUE_PARAMETER: False,
self.C_REDO_PARAMETER: False,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'The command can continue a tube\'s running while it\'s in a loop.'
},
self.C_CREATE_OJBECT: {
self.C_SUPPORT_FROM_VERSION: '2.0.3',
self.C_ALIAS: {'CREATE', 'NEW'},
self.C_ARG_ARGS: [
[True, '-','--', 'str', 1, 'name', True, False, '', '',
'The object instance name (Tube variable name).'],
[False, '-u','--force', '', '', 'is_force', False, True, 'store_true', False,
'Force update even the variable is readonly. Default no.'],
[False, '-g','--global', '', '', 'is_global', False, True, 'store_true', False,
'If update the variable in global tube variables. Default no.'],
],
self.C_CONTINUE_PARAMETER: False,
self.C_REDO_PARAMETER: False,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Create a new object instance.'
},
self.C_TAIL_FILE: {
self.C_SUPPORT_FROM_VERSION: '2.0.0',
self.C_ALIAS: {'TAIL'},
self.C_ARG_ARGS: [
[False, '-f','--file', 'str', '+', 'file', True, False, '', '',
'The text file you want to tail.'],
[False, '-l','--lines', 'str', 1, 'lines', True, False, '', '',
'The lines count you want to output.'],
[False, '-k','--keywords', 'str', '*', 'keywords', False, False, '', '',
'Output start from the given keywords.'],
[False, '-r','--result', 'str', 1, 'result', False, False, '', '',
'The text file to store the tail result.'],
[False, '-v','--variable', 'str', 1, 'variable', False, False, '', '',
'The tube variable name to store the tail result as lines.'],
[False, '-u','--force', '', '', 'is_force', False, True, 'store_true', False,
'Force update even the variable is readonly. Default no.'],
[False, '-g','--global', '', '', 'is_global', False, True, 'store_true', False,
'If update the variable in global tube variables. Default no.'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Print/Log the last N lines of given file.'
},
self.C_FILE_EXIST: {
self.C_SUPPORT_FROM_VERSION: '2.0.2',
self.C_ALIAS: {'F_EXIST'},
self.C_ARG_ARGS: [
[False, '-f','--file', 'str', 1, 'file', True, False, '', '',
'The file name you want to check.'],
[False, '-v','--variable', 'str', 1, 'variable', True, False, '', '',
'The tube variable name to store the exist result. (True/False)'],
[False, '-u','--force', '', '', 'is_force', False, True, 'store_true', False,
'Force update even the variable is readonly. Default no.'],
[False, '-g','--global', '', '', 'is_global', False, True, 'store_true', False,
'If update the variable in global tube variables. Default no.'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Check if a file exists.'
},
self.C_FILE_POP: {
self.C_SUPPORT_FROM_VERSION: '2.0.2',
self.C_ALIAS: {'F_POP'},
self.C_ARG_ARGS: [
[True, '-','--', 'str', '*', 'file', False, False, '', '',
'The text file name you want to pop.'],
[False, '-f','--file', 'str', 1, 'afile', False, False, '', '',
'The text file name you want to pop. It will override the file argument.'],
[False, '-v','--variable', 'str', 1, 'variable', False, False, '', '',
'The tube variable name to store the line content result.'],
[False, '-n','--number', 'str', 1, 'number', False, False, '', '',
'The line number you want to pop. Default 1 to pop the first line. -1 to pop the last line.'],
[False, '-u','--force', '', '', 'is_force', False, True, 'store_true', False,
'Force update even the variable is readonly. Default no.'],
[False, '-g','--global', '', '', 'is_global', False, True, 'store_true', False,
'If update the variable in global tube variables. Default no.'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Pop one line of the given text file. If there is no line there then store empty.'
},
self.C_FILE_APPEND: {
self.C_SUPPORT_FROM_VERSION: '2.0.2',
self.C_ALIAS: {'F_APPEND'},
self.C_ARG_ARGS: [
[False, '-f','--file', 'str', '+', 'file', True, False, '', '',
'The text file name you want to append.'],
[False, '-v','--value', 'str', '+', 'value', True, False, '', '',
'The content you want to append to the text file.'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Append the content to the last line of the given text file.'
},
self.C_FILE_PUSH: {
self.C_SUPPORT_FROM_VERSION: '2.0.2',
self.C_ALIAS: {'F_PUSH'},
self.C_ARG_ARGS: [
[False, '-f','--file', 'str', 1, 'file', True, False, '', '',
'The text file name you want to push.'],
[False, '-v','--value', 'str', '+', 'value', True, False, '', '',
'The content you want to push to the text file.'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Push the content to the first line of the given text file.'
},
self.C_FILE_INSERT: {
self.C_SUPPORT_FROM_VERSION: '2.0.2',
self.C_ALIAS: {'F_INSERT'},
self.C_ARG_ARGS: [
[False, '-f','--file', 'str', '+', 'file', True, False, '', '',
'The file you want to insert.'],
[False, '-n','--number', 'str', 1, 'number', True, False, '', '',
'The line number you want to inert. 1 means the first line, -1 means the last line.'],
[False, '-v','--value', 'str', '+', 'value', True, False, '', '',
'The line you want to insert into the file.'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Insert a line before given line number. If line number doesnot exist then insert to the end.'
},
self.C_FILE_SORT: {
self.C_SUPPORT_FROM_VERSION: '2.0.2',
self.C_ALIAS: {'F_SORT'},
self.C_ARG_ARGS: [
[True, '-','--', 'str', '*', 'file', False, False, '', '',
'The file you want to sort.'],
[False, '-f','--file', 'str', 1, 'afile', False, False, '', '',
'The file you want to sort. It will override file argument.'],
[False, '-n','--number', '', '', 'is_number', False, True, 'store_true', False,
'If sort file line content as numbers. Default No.'],
[False, '-s','--sort', 'str', 1, 'sort', False, False, '', '',
'Default value is asc. You can set value \'desc\' to reverse the sorting.'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Sort a text file lines content.'
},
self.C_FILE_EMPTY: {
self.C_SUPPORT_FROM_VERSION: '2.0.2',
self.C_ALIAS: {'F_EMPTY'},
self.C_ARG_ARGS: [
[True, '-','--', 'str', '*', 'file', False, False, '', '',
'The text file name you want to empty.'],
[False, '-f','--file', 'str', 1, 'afile', False, False, '', '',
'The text file name you want to empty. It will override the file argument.'],
[False, '-c','--create', '', '', 'is_create', False, True, 'store_true', False,
'If the give file doesnot exist if create a new empty file. Default No.'],
[False, '-n','--number', 'str', 1, 'empty_lines', False, False, '', '',
'Add N empty lines to the empty file. [2.0.8]'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Clear an existing text file or create a new empty file.'
},
self.C_FILE_CREATE: {
self.C_SUPPORT_FROM_VERSION: '2.0.2',
self.C_ALIAS: {'F_CREATE'},
self.C_ARG_ARGS: [
[True, '-','--', 'str', '*', 'file', False, False, '', '',
'The text file name you want to create.'],
[False, '-f','--file', 'str', 1, 'afile', False, False, '', '',
'The text file name you want to create. It will override the file argument.'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Create an empty file.'
},
self.C_FILE_READ: {
self.C_SUPPORT_FROM_VERSION: '2.0.2',
self.C_ALIAS: {'F_READ'},
self.C_ARG_ARGS: [
[False, '-f','--file', 'str', '+', 'file', True, False, '', '',
'The file name you want to read its whole content.'],
[False, '-c','--content', 'str', 1, 'content', False, False, '', '',
'The tube variable name to store the file content.'],
[False, '-l','--lines', 'str', 1, 'lines', False, False, '', '',
'The tube variable name to store the file content as lines.'],
[False, '-s','--skip-empty', '', '', 'skip_empty', False, True, 'store_true', False,
'If skip empty lines. Default no.'],
[False, '-u','--force', '', '', 'is_force', False, True, 'store_true', False,
'Force update even the variable is readonly. Default no.'],
[False, '-g','--global', '', '', 'is_global', False, True, 'store_true', False,
'If update the variable in global tube variables. Default no.'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Read a file content to tube variable. Doesn\'t include the new-line (\\n) char.'
},
self.C_FILE_DELETE: {
self.C_SUPPORT_FROM_VERSION: '2.0.2',
self.C_ALIAS: {'F_DELETE', 'F_DEL'},
self.C_ARG_ARGS: [
[True, '-','--', 'str', '*', 'file', False, False, '', '',
'The file name you want to delete. eg: \'*.txt\'.'],
[False, '-f','--file', 'str', 1, 'afile', False, False, '', '',
'The text file name you want to delete. It will override the file argument.'],
[False, '-r','--recursive', '', '', 'recursive', False, True, 'store_true', False,
'If delete files recursively. Default no. [2.0.8]'],
[False, '-t','--text', 'str', 1, 'result', False, False, '', '',
'The text file to store deleted files result.'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Delete any files math the file name.'
},
self.C_FILE_COPY: {
self.C_SUPPORT_FROM_VERSION: '2.0.2',
self.C_ALIAS: {'F_COPY', 'F_CP'},
self.C_ARG_ARGS: [
[False, '-s|-f','--src|--from', 'str', '+', 'src', True, False, '', '',
'The source file name you want to copy.'],
[False, '-d|-t','--dest|--to', 'str', '+', 'dest', True, False, '', '',
'The target file or folder'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Copy any files to target.'
},
self.C_FILE_MOVE: {
self.C_SUPPORT_FROM_VERSION: '2.0.2',
self.C_ALIAS: {'F_MOVE', 'F_MV'},
self.C_ARG_ARGS: [
[False, '-s|-f','--src|--from', 'str', '+', 'src', True, False, '', '',
'The source file name you want to move.'],
[False, '-d|-t','--dest|--to', 'str', '+', 'dest', True, False, '', '',
'The target file or folder'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Move any files to target.'
},
self.C_FILE_DOWNLOAD: {
self.C_SUPPORT_FROM_VERSION: '2.0.3',
self.C_ALIAS: {'DOWNLOAD'},
self.C_ARG_ARGS: [
[False, '-u','--url', 'str', '+', 'url', True, False, '', '',
'The file url.'],
[False, '-f','--file', 'str', '+', 'file', True, False, '', '',
'The file name to save.'],
[False, '-','--timeout', 'str', 1, 'timeout', False, False, '', '',
'The timeout seconds to download the file. Default no timeout.'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Download a file from internet using requests.get().'
},
self.C_DIR_EXIST: {
self.C_SUPPORT_FROM_VERSION: '2.0.2',
self.C_ALIAS: {'D_EXIST'},
self.C_ARG_ARGS: [
[False, '-d','--dir', 'str', 1, 'directory', True, False, '', '',
'The directory you want to check.'],
[False, '-v','--variable', 'str', 1, 'variable', True, False, '', '',
'The tube variable name to store the exist result. (True/False)'],
[False, '-u','--force', '', '', 'is_force', False, True, 'store_true', False,
'Force update even the variable is readonly. Default no.'],
[False, '-g','--global', '', '', 'is_global', False, True, 'store_true', False,
'If update the variable in global tube variables. Default no.'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Check if a directory exists.'
},
self.C_DIR_CREATE: {
self.C_SUPPORT_FROM_VERSION: '2.0.2',
self.C_ALIAS: {'D_CREATE'},
self.C_ARG_ARGS: [
[True, '-','--', 'str', 1, 'directory', True, False, '', '',
'The directory you want to create.'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Create a directory if it doesnot exist.'
},
self.C_DIR_DELETE: {
self.C_SUPPORT_FROM_VERSION: '2.0.2',
self.C_ALIAS: {'D_DELETE', 'D_DEL'},
self.C_ARG_ARGS: [
[True, '-','--', 'str', 1, 'directory', True, False, '', '',
'The directory you want to delete.'],
[False, '-f','--force', '', '', 'is_force', False, True, 'store_true', False,
'Force delete if the director is not empty. Default no.'],
[False, '-r','--result', 'str', 1, 'result', False, False, '', '',
'The text file to store deleted directory result.'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Delete a directory and its sub-directories.'
},
self.C_DELETE_LINE_IN_FILE: {
self.C_SUPPORT_FROM_VERSION: '2.0.0',
self.C_ALIAS: {'DELETE_LINE', 'DEL_LINE', 'DEL_LN'},
self.C_ARG_ARGS: [
[False, '-f','--file', 'str', '+', 'file', True, False, '', '',
'The file you want to delete lines from.'],
[False, '-n','--number', 'str', 1, 'number', False, False, '', '',
'The line number you want to delete. 1 is the first line, -1 is the last line.'],
[False, '-b','--begins', 'str', '+', 'begins', False, False, '', '',
'The line begins with character you want to delete.'],
[False, '-c','--contains', 'str', '+', 'contains', False, False, '', '',
'The line contains with character you want to delete.'],
[False, '-e','--empty', '', '', 'del_empty', False, True, 'store_true', False,
'A flag to tell if delete empty line. Default no.'],
[False, '-r','--result', 'str', 1, 'result', False, False, '', '',
'The text file to store deleted result.'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Conditionally delete lines from a file.'
},
self.C_READ_LINE_IN_FILE: {
self.C_SUPPORT_FROM_VERSION: '2.0.2',
self.C_ALIAS: {'READ_LINE', 'READ_LN'},
self.C_ARG_ARGS: [
[False, '-f','--file', 'str', '+', 'file', True, False, '', '',
'The file you want to read a line from.'],
[False, '-n','--number', 'str', 1, 'number', True, False, '', '',
'The line number you want to read. 1 is the first line, -1 is the last line. If the number is greater than file lines then return the last line.'],
[False, '-v','--variable', 'str', 1, 'variable', True, False, '', '',
'The tube variable name to save the line content.'],
[False, '-u','--force', '', '', 'is_force', False, True, 'store_true', False,
'Force update even the varialbe is readonly. Default no.'],
[False, '-g','--global', '', '', 'is_global', False, True, 'store_true', False,
'If update the variable in global tube variables. Default no.'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Read one line by given line number, and save the line content to tube variable.'
},
self.C_WRITE_LINE_IN_FILE: {
self.C_SUPPORT_FROM_VERSION: '2.0.0',
self.C_ALIAS: {'WRITE_LINE', 'WRITE_LN'},
self.C_ARG_ARGS: [
[False, '-f','--file', 'str', '+', 'file', True, False, '', '',
'The file you want to update.'],
[False, '-v','--value', 'str', '+', 'value', True, False, '', '',
'The character value you want to update in the file.'],
[False, '-n','--number', 'str', 1, 'number', False, False, '', '',
'The line number you want to update. If not provided then append the value to the file.'],
[False, '-c','--contains', 'str', '+', 'contains', False, False, '', '',
'Only update the line if it contains the given characters content.'],
[False, '-b','--begins', 'str', '+', 'begins', False, False, '', '',
'The line begins with character you want to update. [2.0.8]'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Write any characters into a file.'
},
self.C_SET_FILE_KEY_VALUE: {
self.C_SUPPORT_FROM_VERSION: '2.0.0',
self.C_ALIAS: {'SET_KEY'},
self.C_ARG_ARGS: [
[False, '-f','--file', 'str', '+', 'file', True, False, '', '',
'The file you want to update.'],
[False, '-k','--keywords', 'str', '+', 'keywords', True, False, '', '',
'The key in the left side of \'=\'.'],
[False, '-v','--value', 'str', '*', 'value', True, False, '', '',
'The value in the right side of \'=\'.'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Update key-value file.'
},
self.C_GET_XML_TAG_TEXT: {
self.C_SUPPORT_FROM_VERSION: '2.0.0',
self.C_ALIAS: {'GET_XML_TAG'},
self.C_ARG_ARGS: [
[False, '-f','--file', 'str', '+', 'file', True, False, '', '',
'The XML file you want to get tag text.'],
[False, '-x','--xpath', 'str', '+', 'xpath', True, False, '', '',
'The xpath of the XML tag.'],
[False, '-v','--variable', 'str', 1, 'variable', False, False, '', '',
'The tube variable name to store the value. [2.0.2]'],
[False, '-u','--force', '', '', 'is_force', False, True, 'store_true', False,
'Force update even the variable is readonly. Default no. [2.0.2]'],
[False, '-g','--global', '', '', 'is_global', False, True, 'store_true', False,
'If update the variable in global tube variables. Default no. [2.0.2]'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Get XML file tag text value. \
\nThe result will be stored into a tube variable and xpath will be used as the variable name.'
},
self.C_SET_XML_TAG_TEXT: {
self.C_SUPPORT_FROM_VERSION: '2.0.0',
self.C_ALIAS: {'SET_XML_TAG'},
self.C_ARG_ARGS: [
[False, '-f','--file', 'str', '+', 'file', True, False, '', '',
'The XML file you want tup set tag text.'],
[False, '-x','--xpath', 'str', '+', 'xpath', True, False, '', '',
'The xpath of the XML tag'],
[False, '-v','--value', 'str', '+', 'value', True, False, '', '',
'The new value of the tag.'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Update XML file tag text using xpath.'
},
self.C_SET_VARIABLE: {
self.C_SUPPORT_FROM_VERSION: '2.0.0',
self.C_ALIAS: {'SET_VAR', 'SET'},
self.C_ARG_ARGS: [
[True, '-','--', 'str', '*', 'expression', False, False, '', '',
'Assign variable value with format: var_name = expression, var_name["keyword"] = expression or var_name[index] = expression; \
\n{0:18s}You can also use operator +=, -=, *=, /+ to make the assignment eaiser: i += 1, i *= -1 etc; \
\n{0:18s}Or you can use --name, --keyword, --index, --value arguments to set the variable value explicitly.'.format(' ')],
[False, '-n','--name', 'str', 1, 'name', False, False, '', '',
'The tube variable name you want to set.'],
[False, '-k','--keyword', 'str', 1, 'keyword', False, False, '', '',
'If update a dictional type variable, this --keyword value is to set the dict key.'],
[False, '-i','--index', 'str', 1, 'index', False, False, '', '',
'If update a list type variable, this --index value is to set list index.'],
[False, '-v','--value', 'str', '*', 'value', False, False, '', '',
'The tube variable value you want to set. \n \
Note: The backend is using \'eval(expression)\' so you can do more things, eg: \n \
- set_var: -n dayOfWeek -v datetime.today().weekday() # Tube variable dayOfWeek will be set to weekday() value. \n \
- set_var: ls = [1,2,3] # Tube variable ls was updated to list value: [1,2,3]. \n \
- set_var: ls = ls.append(4) # Tube variable ls appended value 4 to its end: [1,2,3,4].'],
[False, '-r','--readonly', '', '', 'is_readonly', False, True, 'store_true', False,
'Mark the variable as readonly after updating. Default no. [2.0.2]'],
[False, '-u','--force', '', '', 'is_force', False, True, 'store_true', False,
'Force update even the varialbe is readonly. Default no. [2.0.2]'],
[False, '-g','--global', '', '', 'is_global', False, True, 'store_true', False,
'If set the variable to global (Main TUBE).\n \
With this flag, it will try to find the first variable from current and its parent tube chain that mathes the input variable name, and update its value. \n \
If found nothing then the variable will be updated in the main tube. \n \
Without this flag, it will update the variable in current tube. \n \
Default no. [2.0.2]'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Set tube variable value.'
},
self.C_SET_TUBE: {
self.C_SUPPORT_FROM_VERSION: '2.0.2',
self.C_ALIAS: {'SET_T'},
self.C_ARG_ARGS: [
[False, '-c','--continue-all', 'str', 1, 'continue_all', False, False, '', '', ['yes', 'Yes', 'True', 'true', 'no', 'No', 'False', 'false'],
'Enable/disable tube\'s command --continue status. Values: yes/no, true/false.'],
[False, '-r','--redo-all', 'str', 1, 'redo_all', False, False, '', '', ['yes', 'Yes', 'True', 'true', 'no', 'No', 'False', 'false'],
'Enable/disable tube\'s command --redo status. Values: yes/no, true/false.'],
[False, '-k','--key-all', 'str', 1, 'key_all', False, False, '', '', ['yes', 'Yes', 'True', 'true', 'no', 'No', 'False', 'false'],
'Enable/disable tube\'s command --key status. Values: yes/no, true/false.'],
[False, '-e','--ending|--finally', 'str', 1, 'ending_tube', False, False, '', '',
'The tube you want to run for ending. It supports 3 formats: \
\n{0:20s} - \'file.yaml\': Run TUBE from file.yaml file. With this format the global variables in file.xml will also be imported. \
\n{0:20s} - \'file[X]\': Run tube X from file.yaml file. \
\n{0:20s} - \'X\': Run tube X from the current yaml file.'.format(' ')],
[False, '-','--key-ending', '', '', 'is_ending_key', False, True, 'store_true', False,
'Add ending tube --key argument.'],
],
self.C_CONTINUE_PARAMETER: False,
self.C_REDO_PARAMETER: False,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: False,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Enable or disable tube commands general arguments for: --continue, --redo or --key. \
\nSet tube\'s ending tube.'
},
self.C_DELETE_VARIABLE: {
self.C_SUPPORT_FROM_VERSION: '2.0.2',
self.C_ALIAS: {'DELETE_VAR', 'DEL_VAR'},
self.C_ARG_ARGS: [
[True, '-','--', 'str', '+', 'name', True, False, '', '',
'The tube variable name you want to delete from current tube.'],
[False, '-g','--global', '', '', 'is_global', False, True, 'store_true', False,
'With --global parameter you can delete it from current and its parent tubes.'],
[False, '-a','--all', '', '', 'is_del_all', False, True, 'store_true', False,
'With --all parameter you can delete it from all tubes.'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'Delete tube variables.'
},
self.C_CONNECT: {
self.C_SUPPORT_FROM_VERSION: '2.0.0',
self.C_ALIAS: {'CONN'},
self.C_ARG_ARGS: [
[True, '-','--', 'str', '+', 'host', True, False, '', '',
'The Linux server host or name you want to connect using SSH protocal.'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'You can use this command to switch your server connection.'
},
self.C_REPORT_PROGRESS: {
self.C_SUPPORT_FROM_VERSION: '2.0.0',
self.C_ALIAS: {'REPORT_PRO'},
self.C_ARG_ARGS: [
[True, '-','--', 'str', '+', 'subject', True, False, '', '',
'The email subject/title you want to set.'],
],
self.C_CONTINUE_PARAMETER: True,
self.C_REDO_PARAMETER: True,
self.C_IF_PARAMETER: True,
self.C_KEY_PARAMETER: True,
self.C_PLACE_HOLDER: True,
self.C_RAW_LOG: True,
self.C_NOTES_PARAMETER: True,
self.C_COMMAND_DESCRIPTION: 'You can use this command to sent current progress via Email.'
},
self.C_REQUESTS_GET: {
self.C_SUPPORT_FROM_VERSION: '2.0.3',
self.C_ALIAS: {'HTTP_GET'},
self.C_ARG_ARGS: [
[True, '-','--', 'str', '+', 'url', True, False, '', '',
'The request url.'],
[False, '-a','--args', 'str', '*', 'parameters', False, False, '', '',
'The parameters of requests.get() method. eg: --args params=xxx, data=yyy'],
[False, '-r','--resp', 'str', 1, 'response', False, False, '', '',
f'The tube variable name to store http get response. \
\n{" ":16s}Then you can access response properties: status_code, url, headers, text, json(), etc. \
\n{" ":16s}Refer to: https://requests.readthedocs.io/en/latest/user/quickstart/#response-content'],
[False, '-s','--soup', 'str', 1, 'soup', False, False, '', '',
'Tube variable name of BeautifulSoup object. (Use Response.Text content with lxml parser)'],
[False, '-u','--force', '', '', 'is_force', False, True, 'store_true', False,
'Force update even the variable is readonly. Default no.'],
[False, '-g','--global', '', '', 'is_global', False, True, 'store_true', False,