multiscript-windows 1.0.1__tar.gz → 1.0.3__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.4
2
2
  Name: multiscript-windows
3
- Version: 1.0.1
3
+ Version: 1.0.3
4
4
  Summary: A lightweight wrapper to run Batch and VBScript within Python.
5
5
  Author-email: KingTheCoder <kingjd490@gmail.com>
6
6
  License: GPL-3.0-only
@@ -29,31 +29,33 @@ Now, you have three functions exposed to you.
29
29
 
30
30
  Those three functions are `batchscript`, `vbscript` and `commandlist`.
31
31
 
32
- The function `commandlist` gives you a list of commands that you can use in multiscript.
32
+ The function `commandlist` gives you a list of functions that you can use in multiscript.
33
33
 
34
- This includes the `batchscript` and `vbscript` commands and how to use them.
34
+ This includes all other commands and how to use them.
35
35
 
36
- Run this command for more information.
36
+ Run this function for more information.
37
37
 
38
- The `batchscript` command executes batch in a string.
38
+ The `batchscript` function executes batch in a string.
39
39
 
40
40
  Example:
41
41
 
42
42
  ```
43
43
  import multiscript
44
44
 
45
- batchscript(
45
+ prn = batchscript(
46
46
  r"""
47
47
  move test.txt .\destination
48
48
  del deleteme.png
49
49
  echo Test Complete!
50
50
  """
51
51
  )
52
+
53
+ print(prn)
52
54
 
53
55
  print("And we're still in python!")
54
56
  ```
55
57
 
56
- The `vbscript` command executes visual basic in a string.
58
+ The `vbscript` function executes visual basic in a string.
57
59
 
58
60
  Example:
59
61
 
@@ -70,6 +72,24 @@ vbscript(
70
72
  print("And we can still use more python!")
71
73
  ```
72
74
 
75
+ The `javascript` function executes javascript in a string.
76
+
77
+ Example:
78
+
79
+ ```
80
+ import multiscript
81
+
82
+ print(
83
+ javascript(
84
+ """
85
+ WScript.Echo("Hello, World!")
86
+ """
87
+ )
88
+ )
89
+
90
+ print("All within python!")
91
+ ```
92
+
73
93
  ## Licensing
74
94
 
75
95
  Licensed under the GNU General Public License v3 (GPLv3).
@@ -84,6 +104,14 @@ All of the versions of multiscript.
84
104
 
85
105
  Fixed a bug where enabling `showreturncode` for the `vbscript` function would cause a `TypeError`.
86
106
 
107
+ ## 1.0.2
108
+
109
+ Fixed a bug where running two of the same function at the same time would overwrite temp file A with temp file B.
110
+
111
+ ## 1.0.3
112
+
113
+ Added the `javascript` function.
114
+
87
115
  ## Some Extra
88
116
 
89
117
  Hey, thanks for reading all the way to the end!
@@ -13,31 +13,33 @@ Now, you have three functions exposed to you.
13
13
 
14
14
  Those three functions are `batchscript`, `vbscript` and `commandlist`.
15
15
 
16
- The function `commandlist` gives you a list of commands that you can use in multiscript.
16
+ The function `commandlist` gives you a list of functions that you can use in multiscript.
17
17
 
18
- This includes the `batchscript` and `vbscript` commands and how to use them.
18
+ This includes all other commands and how to use them.
19
19
 
20
- Run this command for more information.
20
+ Run this function for more information.
21
21
 
22
- The `batchscript` command executes batch in a string.
22
+ The `batchscript` function executes batch in a string.
23
23
 
24
24
  Example:
25
25
 
26
26
  ```
27
27
  import multiscript
28
28
 
29
- batchscript(
29
+ prn = batchscript(
30
30
  r"""
31
31
  move test.txt .\destination
32
32
  del deleteme.png
33
33
  echo Test Complete!
34
34
  """
35
35
  )
36
+
37
+ print(prn)
36
38
 
37
39
  print("And we're still in python!")
38
40
  ```
39
41
 
40
- The `vbscript` command executes visual basic in a string.
42
+ The `vbscript` function executes visual basic in a string.
41
43
 
42
44
  Example:
43
45
 
@@ -54,6 +56,24 @@ vbscript(
54
56
  print("And we can still use more python!")
55
57
  ```
56
58
 
59
+ The `javascript` function executes javascript in a string.
60
+
61
+ Example:
62
+
63
+ ```
64
+ import multiscript
65
+
66
+ print(
67
+ javascript(
68
+ """
69
+ WScript.Echo("Hello, World!")
70
+ """
71
+ )
72
+ )
73
+
74
+ print("All within python!")
75
+ ```
76
+
57
77
  ## Licensing
58
78
 
59
79
  Licensed under the GNU General Public License v3 (GPLv3).
@@ -68,6 +88,14 @@ All of the versions of multiscript.
68
88
 
69
89
  Fixed a bug where enabling `showreturncode` for the `vbscript` function would cause a `TypeError`.
70
90
 
91
+ ## 1.0.2
92
+
93
+ Fixed a bug where running two of the same function at the same time would overwrite temp file A with temp file B.
94
+
95
+ ## 1.0.3
96
+
97
+ Added the `javascript` function.
98
+
71
99
  ## Some Extra
72
100
 
73
101
  Hey, thanks for reading all the way to the end!
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "multiscript-windows"
7
- version = "1.0.1"
7
+ version = "1.0.3"
8
8
  authors = [
9
9
  { name="KingTheCoder", email="kingjd490@gmail.com" },
10
10
  ]
@@ -0,0 +1,65 @@
1
+ import os, subprocess, uuid
2
+
3
+ def gentempname(ext):
4
+ return "tmp_" + uuid.uuid4().hex[:16] + ext
5
+
6
+ def batchscript(scr, err=False, rcd=False):
7
+ fname = gentempname(".bat")
8
+ with open(fname, "w") as batfile:
9
+ batfile.write(scr)
10
+ snd = subprocess.run(["cmd.exe", "/c", fname], capture_output=True, text=True)
11
+ rtn = snd.stdout
12
+ if err:
13
+ rtn = (rtn + "\n" + snd.stderr)
14
+ if rcd:
15
+ rtn = (rtn + "\n" + str(snd.returncode))
16
+ os.remove(fname)
17
+ return rtn
18
+ def commandlist():
19
+ print(
20
+ """
21
+ -=#COMMANDS#=-
22
+ batchscript(script, showerrorcode, showreturncode)
23
+ Runs a batch script.
24
+ If not specified, showerrorcode and showreturncode will be set to False.
25
+ vbscript(script, showerrorcode, showreturncode, usewscript)
26
+ Runs a visual basic script.
27
+ If not specified, showerrorcode, showreturncode and usewscript will be set to False.
28
+ The usewscript argument controls if cscript or wscript is used to execute.
29
+ javascript(script, showerrorcode, showreturncode, usewscript)
30
+ Runs a javascript program.
31
+ If not specified, showerrorcode, showreturncode and usewscript will be set to False.
32
+ The usewscript argument controls if cscript or wscript is used to execute.
33
+ """
34
+ )
35
+ def vbscript(scr, err=False, rcd=False, wsc=False):
36
+ fname = gentempname(".vbs")
37
+ with open(fname, "w") as vbsfile:
38
+ vbsfile.write(scr)
39
+ if wsc:
40
+ snd = subprocess.run(["wscript.exe", fname], capture_output=True, text=True)
41
+ else:
42
+ snd = subprocess.run(["cscript.exe", "//Nologo", fname], capture_output=True, text=True)
43
+ rtn = snd.stdout
44
+ if err:
45
+ rtn = (rtn + "\n" + snd.stderr)
46
+ if rcd:
47
+ rtn = (rtn + "\n" + str(snd.returncode))
48
+ os.remove(fname)
49
+ return rtn
50
+ def javascript(scr, err=False, rcd=False, wsc=False):
51
+ fname = gentempname(".js")
52
+ with open(fname, "w") as jsfile:
53
+ jsfile.write(scr)
54
+ if wsc:
55
+ snd = subprocess.run(["wscript.exe", "//E:jscript", fname], capture_output=True, text=True)
56
+ else:
57
+ snd = subprocess.run(["cscript.exe", "//Nologo", "//E:jscript", fname], capture_output=True, text=True)
58
+ rtn = snd.stdout
59
+ if err:
60
+ rtn = rtn + "\n" + snd.stderr
61
+ if rcd:
62
+ rtn = rtn + "\n" + str(snd.returncode)
63
+ os.remove(fname)
64
+ return rtn
65
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: multiscript-windows
3
- Version: 1.0.1
3
+ Version: 1.0.3
4
4
  Summary: A lightweight wrapper to run Batch and VBScript within Python.
5
5
  Author-email: KingTheCoder <kingjd490@gmail.com>
6
6
  License: GPL-3.0-only
@@ -29,31 +29,33 @@ Now, you have three functions exposed to you.
29
29
 
30
30
  Those three functions are `batchscript`, `vbscript` and `commandlist`.
31
31
 
32
- The function `commandlist` gives you a list of commands that you can use in multiscript.
32
+ The function `commandlist` gives you a list of functions that you can use in multiscript.
33
33
 
34
- This includes the `batchscript` and `vbscript` commands and how to use them.
34
+ This includes all other commands and how to use them.
35
35
 
36
- Run this command for more information.
36
+ Run this function for more information.
37
37
 
38
- The `batchscript` command executes batch in a string.
38
+ The `batchscript` function executes batch in a string.
39
39
 
40
40
  Example:
41
41
 
42
42
  ```
43
43
  import multiscript
44
44
 
45
- batchscript(
45
+ prn = batchscript(
46
46
  r"""
47
47
  move test.txt .\destination
48
48
  del deleteme.png
49
49
  echo Test Complete!
50
50
  """
51
51
  )
52
+
53
+ print(prn)
52
54
 
53
55
  print("And we're still in python!")
54
56
  ```
55
57
 
56
- The `vbscript` command executes visual basic in a string.
58
+ The `vbscript` function executes visual basic in a string.
57
59
 
58
60
  Example:
59
61
 
@@ -70,6 +72,24 @@ vbscript(
70
72
  print("And we can still use more python!")
71
73
  ```
72
74
 
75
+ The `javascript` function executes javascript in a string.
76
+
77
+ Example:
78
+
79
+ ```
80
+ import multiscript
81
+
82
+ print(
83
+ javascript(
84
+ """
85
+ WScript.Echo("Hello, World!")
86
+ """
87
+ )
88
+ )
89
+
90
+ print("All within python!")
91
+ ```
92
+
73
93
  ## Licensing
74
94
 
75
95
  Licensed under the GNU General Public License v3 (GPLv3).
@@ -84,6 +104,14 @@ All of the versions of multiscript.
84
104
 
85
105
  Fixed a bug where enabling `showreturncode` for the `vbscript` function would cause a `TypeError`.
86
106
 
107
+ ## 1.0.2
108
+
109
+ Fixed a bug where running two of the same function at the same time would overwrite temp file A with temp file B.
110
+
111
+ ## 1.0.3
112
+
113
+ Added the `javascript` function.
114
+
87
115
  ## Some Extra
88
116
 
89
117
  Hey, thanks for reading all the way to the end!
@@ -1,41 +0,0 @@
1
- import os
2
- import subprocess
3
-
4
- def batchscript(scr, err=False, rcd=False):
5
- with open("temp.bat", "w") as batfile:
6
- batfile.write(scr)
7
- snd = subprocess.run(["cmd.exe", "/c", "temp.bat"], capture_output=True, text=True)
8
- rtn = snd.stdout
9
- if err:
10
- rtn = (rtn + "\n" + snd.stderr)
11
- if rcd:
12
- rtn = (rtn + "\n" + str(snd.returncode))
13
- os.remove("temp.bat")
14
- return rtn
15
- def commandlist():
16
- print(
17
- """
18
- -=#COMMANDS#=-
19
- batchscript(script, showerrorcode, showreturncode)
20
- Runs a batch script.
21
- If not specified, showerrorcode and showreturncode will be set to False.
22
- vbscript(script, showerrorcode, showreturncode, usewscript)
23
- Runs a visual basic script.
24
- If not specified, showerrorcode, showreturncode and usewscript will be set to False.
25
- The usewscript argument controls if cscript or wscript is used to execute.
26
- """
27
- )
28
- def vbscript(scr, err=False, rcd=False, wsc=False):
29
- with open("temp.vbs", "w") as vbsfile:
30
- vbsfile.write(scr)
31
- if wsc:
32
- snd = subprocess.run(["wscript.exe", "temp.vbs"], capture_output=True, text=True)
33
- else:
34
- snd = subprocess.run(["cscript.exe", "//Nologo", "temp.vbs"], capture_output=True, text=True)
35
- rtn = snd.stdout
36
- if err:
37
- rtn = (rtn + "\n" + snd.stderr)
38
- if rcd:
39
- rtn = (rtn + "\n" + str(snd.returncode))
40
- os.remove("temp.vbs")
41
- return rtn