funbuild 202306301655__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.
Files changed (29) hide show
  1. funbuild-202306301655/LICENSE +201 -0
  2. funbuild-202306301655/PKG-INFO +8 -0
  3. funbuild-202306301655/README.md +14 -0
  4. funbuild-202306301655/funbuild/__init__.py +0 -0
  5. funbuild-202306301655/funbuild/core/__init__.py +1 -0
  6. funbuild-202306301655/funbuild/core/core.py +187 -0
  7. funbuild-202306301655/funbuild/core/version.py +50 -0
  8. funbuild-202306301655/funbuild/git/__init__.py +0 -0
  9. funbuild-202306301655/funbuild/git/repo.py +0 -0
  10. funbuild-202306301655/funbuild/manage/__init__.py +1 -0
  11. funbuild-202306301655/funbuild/manage/core.py +85 -0
  12. funbuild-202306301655/funbuild/manage/port.md +2 -0
  13. funbuild-202306301655/funbuild/manage/supervisord.conf +174 -0
  14. funbuild-202306301655/funbuild/shell/__init__.py +5 -0
  15. funbuild-202306301655/funbuild/shell/core.py +36 -0
  16. funbuild-202306301655/funbuild/temp/__init__.py +0 -0
  17. funbuild-202306301655/funbuild/temp/core.json +6 -0
  18. funbuild-202306301655/funbuild/temp/core.py +0 -0
  19. funbuild-202306301655/funbuild/tool/__init__.py +1 -0
  20. funbuild-202306301655/funbuild/tool/build.py +7 -0
  21. funbuild-202306301655/funbuild/tool/fastapi.py +33 -0
  22. funbuild-202306301655/funbuild.egg-info/PKG-INFO +8 -0
  23. funbuild-202306301655/funbuild.egg-info/SOURCES.txt +27 -0
  24. funbuild-202306301655/funbuild.egg-info/dependency_links.txt +1 -0
  25. funbuild-202306301655/funbuild.egg-info/entry_points.txt +2 -0
  26. funbuild-202306301655/funbuild.egg-info/requires.txt +1 -0
  27. funbuild-202306301655/funbuild.egg-info/top_level.txt +1 -0
  28. funbuild-202306301655/setup.cfg +4 -0
  29. funbuild-202306301655/setup.py +20 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,8 @@
1
+ Metadata-Version: 2.1
2
+ Name: funbuild
3
+ Version: 202306301655
4
+ Summary: funbuild
5
+ Home-page: https://github.com/1007530194
6
+ Author: bingtao
7
+ Author-email: 1007530194@qq.com
8
+ License-File: LICENSE
@@ -0,0 +1,14 @@
1
+ # funbuild
2
+
3
+ #### pypi打包
4
+
5
+
6
+ #### github
7
+
8
+
9
+ #### github push
10
+
11
+
12
+
13
+
14
+
File without changes
@@ -0,0 +1 @@
1
+ from .core import funbuild
@@ -0,0 +1,187 @@
1
+ """
2
+ 打包的工具类
3
+ """
4
+ import argparse
5
+ import logging
6
+ import os.path
7
+ import time
8
+ from git import Repo
9
+
10
+ from funbuild.shell import run_shell, run_shell_list
11
+
12
+
13
+ class PackageBuild:
14
+ """
15
+ 打包的工具类
16
+ """
17
+
18
+ def __init__(self, name=None):
19
+ self.repo_path = run_shell("git rev-parse --show-toplevel", printf=False)
20
+ self.name = name or self.repo_path.split('/')[-1]
21
+ self.repo = Repo(self.repo_path)
22
+
23
+ # self.git_url = run_shell("git remote -v", printf=False).split('\n')[0].split('\t')[1].split(' ')[0]
24
+ self.git_url = [url for url in self.repo.remote().urls][0]
25
+
26
+ def git_pull(self):
27
+ """
28
+ git pull
29
+ """
30
+ logging.info("{} pull".format(self.name))
31
+ # run_shell("git pull")
32
+ self.repo.remote().pull()
33
+
34
+ def git_push(self):
35
+ """
36
+ git push
37
+ """
38
+ logging.info("{} push".format(self.name))
39
+ run_shell_list([
40
+ 'git add -A',
41
+ 'git commit -a -m "add"',
42
+ 'git push'
43
+ ])
44
+ self.repo.index.add(f"{self.repo_path}/*")
45
+ self.repo.index.commit(message='add')
46
+ self.repo.remote().pull()
47
+
48
+ def git_install(self):
49
+ """
50
+ git install
51
+ """
52
+ logging.info('{} install'.format(self.name))
53
+ run_shell_list([
54
+ 'pip uninstall {} -y'.format(self.name),
55
+ 'python3 setup.py install',
56
+ 'rm -rf *.egg-info',
57
+ 'rm -rf dist',
58
+ 'rm -rf build'
59
+ ])
60
+ self.git_clear_build()
61
+
62
+ def pip_install(self):
63
+ """
64
+ pip install
65
+ """
66
+ run_shell('pip install -U -q git+{}'.format(self.git_url))
67
+ logging.info('pip install {} success'.format(self.name))
68
+
69
+ def git_clear_build(self):
70
+ logging.info('{} build clear'.format(self.name))
71
+ run_shell_list([
72
+ 'rm -rf *.egg-info',
73
+ 'rm -rf dist',
74
+ 'rm -rf build',
75
+ ])
76
+
77
+ def git_build(self):
78
+ """
79
+ git build
80
+ """
81
+ logging.info('{} build'.format(self.name))
82
+ self.git_pull()
83
+ self.git_clear_build()
84
+
85
+ set_up_file = 'setup.py'
86
+ if not os.path.exists(set_up_file):
87
+ set_up_file = 'setup2.py'
88
+ if not os.path.exists(set_up_file):
89
+ set_up_file = 'setup3.py'
90
+
91
+ run_shell_list([
92
+ f'python3 {set_up_file} build', # 编译
93
+ f'python3 {set_up_file} sdist', # 生成 tar.gz
94
+ f'python3 {set_up_file} bdist_egg', # 生成 egg 包
95
+ f'python3 {set_up_file} bdist_wheel', # 生成 wheel 包
96
+
97
+ # twine register dist/*
98
+ 'twine upload dist/*' # 发布包
99
+ ])
100
+ self.git_clear_build()
101
+ self.git_push()
102
+ self.git_tags()
103
+ self.pip_install()
104
+
105
+ def git_clean_history(self):
106
+ """
107
+ git build
108
+ """
109
+ logging.info(f'{self.name} clean history')
110
+ run_shell_list([
111
+ 'git tag -d $(git tag -l) || true', # 删除本地 tag
112
+ 'git fetch', # 拉取远程tag
113
+ 'git push origin --delete $(git tag -l)', # 删除远程tag
114
+ "git tag -d $(git tag -l) || true", # 删除本地tag
115
+ 'git checkout --orphan latest_branch', # 1.Checkout
116
+ 'git add -A', # 2.Add all the files
117
+ 'git commit -am "clear history"', # 3.Commit the changes
118
+ 'git branch -D master', # 4.Delete the branch
119
+ 'git branch -m master', # 5.Rename the current branch to master
120
+ 'git push -f origin master', # 6.Finally, force update your repository
121
+ 'git push --set-upstream origin master',
122
+ f'echo {self.name} success'
123
+ ])
124
+
125
+ def git_clean(self):
126
+ """
127
+ git clean
128
+ """
129
+ logging.info('{} clean'.format(self.name))
130
+ run_shell_list([
131
+ 'git rm -r --cached .',
132
+ 'git add .',
133
+ "git commit -m 'update .gitignore'",
134
+ 'git gc --aggressive',
135
+ ])
136
+
137
+ def git_tags(self):
138
+ self.repo.create_tag(time.strftime("%Y%m%d%H%M", time.localtime()))
139
+ self.repo.remote().push()
140
+ self.repo.remote().push(self.repo.tags)
141
+
142
+ def git_tags_clear(self):
143
+ for tag in self.repo.tags:
144
+ self.repo.delete_tag(tag)
145
+ self.repo.remote().push()
146
+ self.repo.remote().push(self.repo.tags)
147
+
148
+
149
+ def command_line_parser():
150
+ parser = argparse.ArgumentParser(description="Test")
151
+ parser.add_argument('command')
152
+ args = parser.parse_args()
153
+ return args
154
+
155
+
156
+ def funbuild():
157
+ """
158
+ build tool
159
+ """
160
+ args = command_line_parser()
161
+ package = PackageBuild()
162
+ if args.command == 'pull':
163
+ package.git_pull()
164
+ elif args.command == 'push':
165
+ package.git_push()
166
+ elif args.command == 'install':
167
+ package.git_install()
168
+ elif args.command == 'build':
169
+ package.git_build()
170
+ elif args.command == 'clean':
171
+ package.git_clean()
172
+ elif args.command == 'clean_history':
173
+ package.git_clean_history()
174
+ elif args.command == 'tags':
175
+ package.git_tags()
176
+ elif args.command == 'help':
177
+ info = """
178
+ build
179
+ pull
180
+ push
181
+ install
182
+ clean
183
+ clean_history
184
+ help
185
+ tags
186
+ """
187
+ print(info)
@@ -0,0 +1,50 @@
1
+ from os import path
2
+
3
+
4
+ class VersionManage:
5
+ def __init__(self, version_path='./script/__version__.md', step=32):
6
+ self.step = step
7
+ self.version_path = version_path
8
+ self.version_arr = [0, 0, 1]
9
+ self.read()
10
+
11
+ @property
12
+ def version(self):
13
+ return '.'.join([str(i) for i in self.version_arr])
14
+
15
+ def add(self):
16
+ step = self.step
17
+ version = self.version_arr
18
+ version2 = version[0] * step * step + version[1] * step + version[2] + 1
19
+ version[2] = version2 % step
20
+ version[1] = int(version2 / step) % step
21
+ version[0] = int(version2 / step / step)
22
+
23
+ self.version_arr = version
24
+
25
+ def read(self):
26
+ if path.exists(self.version_path):
27
+ with open(self.version_path, 'r') as f:
28
+ self.version_arr = [int(i) for i in f.read().split('.')]
29
+ else:
30
+ self.version_arr = [0, 0, 1]
31
+
32
+ def write(self):
33
+ with open(self.version_path, 'w') as f:
34
+ f.write(self.version)
35
+ return self.version
36
+
37
+
38
+ def get_version(argv, version_path, step=10):
39
+ manage = VersionManage(version_path, step=step)
40
+ manage.read()
41
+ if len(argv) >= 2 and argv[1] == 'build':
42
+ manage.add()
43
+ manage.write()
44
+ return manage.version
45
+
46
+
47
+ def read_version(version_path):
48
+ manage = VersionManage(version_path)
49
+ manage.read()
50
+ return manage.version
File without changes
File without changes
@@ -0,0 +1 @@
1
+ from .core import BaseServer, ServerManage
@@ -0,0 +1,85 @@
1
+ import argparse
2
+ import os
3
+
4
+ from funbuild.shell import run_shell
5
+
6
+
7
+ class ServerManage:
8
+ def __init__(self):
9
+ self.manage_conf_path = "/darkchats/funbuild/supervisord.conf"
10
+ self.conf_dir = "/darkchats/funbuild/conf"
11
+
12
+ def init(self):
13
+ run_shell(f"mkdir -p {self.conf_dir}")
14
+ run_shell(f"cp -f {os.path.abspath(os.path.dirname(__file__))}/supervisord.conf {self.manage_conf_path}")
15
+
16
+ def init2(self):
17
+ run_shell(f"mkdir -p {self.conf_dir}")
18
+ run_shell(f"echo_supervisord_conf > {self.manage_conf_path}")
19
+ append_data = f"""
20
+ [include]
21
+ files = {self.conf_dir}/*.ini
22
+ """
23
+ data = open(self.manage_conf_path, 'r').read()
24
+ data += append_data
25
+ with open(self.manage_conf_path, 'w') as f:
26
+ f.write(data)
27
+
28
+ def start(self):
29
+ cmd = f"supervisord -c {self.manage_conf_path}"
30
+ print(cmd)
31
+ run_shell(cmd)
32
+
33
+ def add_job(self, server_name, directory, command, user='bingtao', stdout_logfile=None):
34
+ default_logfile = f'/darkchats/logs/funbuild/{server_name}.log'
35
+ config = f"""[program:{server_name}]
36
+ directory = {directory}
37
+ command = {command}
38
+ autostart = true
39
+ autorestart = true
40
+ user = {user}
41
+ stdout_logfile = {stdout_logfile or default_logfile}
42
+ """
43
+ with open(f'{self.conf_dir}/{server_name}.ini', 'w') as f:
44
+ f.write(config)
45
+
46
+
47
+ class BaseServer:
48
+ def __init__(self, server_name='base_server', current_path=None, *args, **kwargs):
49
+ self.server_name = server_name
50
+ self.current_path = current_path or os.path.abspath(os.path.dirname(__file__))
51
+ self.manage = ServerManage()
52
+ self.parser = argparse.ArgumentParser()
53
+ self.parser.add_argument('cmd', default='unknown', help='init, stop, start, restart')
54
+
55
+ def init(self):
56
+ pass
57
+
58
+ def status(self):
59
+ run_shell(f"supervisorctl -c {self.manage.manage_conf_path} status")
60
+
61
+ def stop(self):
62
+ run_shell(f"supervisorctl -c {self.manage.manage_conf_path} stop {self.server_name}")
63
+
64
+ def start(self):
65
+ run_shell(f"supervisorctl -c {self.manage.manage_conf_path} start {self.server_name}")
66
+
67
+ def restart(self):
68
+ run_shell(f"supervisorctl -c {self.manage.manage_conf_path} restart {self.server_name}")
69
+
70
+ def run(self, cmd):
71
+ print(cmd)
72
+ run_shell(cmd)
73
+
74
+ def parse_and_run(self):
75
+ values, unknown = self.parser.parse_known_args()
76
+ if values.cmd == 'init':
77
+ self.init()
78
+ elif values.cmd == 'stop':
79
+ self.stop()
80
+ elif values.cmd == 'start':
81
+ self.start()
82
+ elif values.cmd == 'restart':
83
+ self.restart()
84
+ else:
85
+ self.parser.print_help()
@@ -0,0 +1,2 @@
1
+ 8101 supervisord
2
+ 8102 celery-flower
@@ -0,0 +1,174 @@
1
+ ; Sample supervisor config file.
2
+ ;
3
+ ; For more information on the config file, please see:
4
+ ; http://supervisord.org/configuration.html
5
+ ;
6
+ ; Notes:
7
+ ; - Shell expansion ("~" or "$HOME") is not supported. Environment
8
+ ; variables can be expanded using this syntax: "%(ENV_HOME)s".
9
+ ; - Quotes around values are not supported, except in the case of
10
+ ; the environment= options as shown below.
11
+ ; - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
12
+ ; - Command will be truncated if it looks like a config file comment, e.g.
13
+ ; "command=bash -c 'foo ; bar'" will truncate to "command=bash -c 'foo ".
14
+ ;
15
+ ; Warning:
16
+ ; Paths throughout this example file use /tmp because it is available on most
17
+ ; systems. You will likely need to change these to locations more appropriate
18
+ ; for your system. Some systems periodically delete older files in /tmp.
19
+ ; Notably, if the socket file defined in the [unix_http_server] section below
20
+ ; is deleted, supervisorctl will be unable to connect to supervisord.
21
+
22
+ ;[unix_http_server]
23
+ ;file=/tmp/supervisor.sock ; the path to the socket file
24
+ ;chmod=0700 ; socket file mode (default 0700)
25
+ ;chown=nobody:nogroup ; socket file uid:gid owner
26
+ ;username=user ; default is no username (open server)
27
+ ;password=123 ; default is no password (open server)
28
+
29
+ ; Security Warning:
30
+ ; The inet HTTP server is not enabled by default. The inet HTTP server is
31
+ ; enabled by uncommenting the [inet_http_server] section below. The inet
32
+ ; HTTP server is intended for use within a trusted environment only. It
33
+ ; should only be bound to localhost or only accessible from within an
34
+ ; isolated, trusted network. The inet HTTP server does not support any
35
+ ; form of encryption. The inet HTTP server does not use authentication
36
+ ; by default (see the username= and password= options to add authentication).
37
+ ; Never expose the inet HTTP server to the public internet.
38
+
39
+ [inet_http_server] ; inet (TCP) server disabled by default
40
+ port=0.0.0.0:8101 ; ip_address:port specifier, *:port for all iface
41
+ ;username=user ; default is no username (open server)
42
+ ;password=123456 ; default is no password (open server)
43
+
44
+ [supervisord]
45
+ logfile=/tmp/supervisord.log ; main log file; default $CWD/supervisord.log
46
+ logfile_maxbytes=50MB ; max main logfile bytes b4 rotation; default 50MB
47
+ logfile_backups=10 ; # of main logfile backups; 0 means none, default 10
48
+ loglevel=info ; log level; default info; others: debug,warn,trace
49
+ pidfile=/tmp/supervisord.pid ; supervisord pidfile; default supervisord.pid
50
+ nodaemon=false ; start in foreground if true; default false
51
+ silent=false ; no logs to stdout if true; default false
52
+ minfds=1024 ; min. avail startup file descriptors; default 1024
53
+ minprocs=200 ; min. avail process descriptors;default 200
54
+ ;umask=022 ; process file creation umask; default 022
55
+ ;user=supervisord ; setuid to this UNIX account at startup; recommended if root
56
+ ;identifier=supervisor ; supervisord identifier, default is 'supervisor'
57
+ ;directory=/tmp ; default is not to cd during start
58
+ ;nocleanup=true ; don't clean up tempfiles at start; default false
59
+ ;childlogdir=/tmp ; 'AUTO' child log dir, default $TEMP
60
+ ;environment=KEY="value" ; key value pairs to add to environment
61
+ ;strip_ansi=false ; strip ansi escape codes in logs; def. false
62
+
63
+ ; The rpcinterface:supervisor section must remain in the config file for
64
+ ; RPC (supervisorctl/web interface) to work. Additional interfaces may be
65
+ ; added by defining them in separate [rpcinterface:x] sections.
66
+
67
+ [rpcinterface:supervisor]
68
+ supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
69
+
70
+ ; The supervisorctl section configures how supervisorctl will connect to
71
+ ; supervisord. configure it match the settings in either the unix_http_server
72
+ ; or inet_http_server section.
73
+
74
+ [supervisorctl]
75
+ #serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
76
+ serverurl=http://0.0.0.0:8101 ; use an http:// url to specify an inet socket
77
+ ;username=admin ; should be same as in [*_http_server] if set
78
+ ;password=123456 ; should be same as in [*_http_server] if set
79
+ ;prompt=mysupervisor ; cmd line prompt (default "supervisor")
80
+ ;history_file=~/.sc_history ; use readline history if available
81
+
82
+ ; The sample program section below shows all possible program subsection values.
83
+ ; Create one or more 'real' program: sections to be able to control them under
84
+ ; supervisor.
85
+
86
+ ;[program:theprogramname]
87
+ ;command=/bin/cat ; the program (relative uses PATH, can take args)
88
+ ;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
89
+ ;numprocs=1 ; number of processes copies to start (def 1)
90
+ ;directory=/tmp ; directory to cwd to before exec (def no cwd)
91
+ ;umask=022 ; umask for process (default None)
92
+ ;priority=999 ; the relative start priority (default 999)
93
+ ;autostart=true ; start at supervisord start (default: true)
94
+ ;startsecs=1 ; # of secs prog must stay up to be running (def. 1)
95
+ ;startretries=3 ; max # of serial start failures when starting (default 3)
96
+ ;autorestart=unexpected ; when to restart if exited after running (def: unexpected)
97
+ ;exitcodes=0 ; 'expected' exit codes used with autorestart (default 0)
98
+ ;stopsignal=QUIT ; signal used to kill process (default TERM)
99
+ ;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
100
+ ;stopasgroup=false ; send stop signal to the UNIX process group (default false)
101
+ ;killasgroup=false ; SIGKILL the UNIX process group (def false)
102
+ ;user=chrism ; setuid to this UNIX account to run the program
103
+ ;redirect_stderr=true ; redirect proc stderr to stdout (default false)
104
+ ;stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO
105
+ ;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
106
+ ;stdout_logfile_backups=10 ; # of stdout logfile backups (0 means none, default 10)
107
+ ;stdout_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
108
+ ;stdout_events_enabled=false ; emit events on stdout writes (default false)
109
+ ;stdout_syslog=false ; send stdout to syslog with process name (default false)
110
+ ;stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO
111
+ ;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
112
+ ;stderr_logfile_backups=10 ; # of stderr logfile backups (0 means none, default 10)
113
+ ;stderr_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
114
+ ;stderr_events_enabled=false ; emit events on stderr writes (default false)
115
+ ;stderr_syslog=false ; send stderr to syslog with process name (default false)
116
+ ;environment=A="1",B="2" ; process environment additions (def no adds)
117
+ ;serverurl=AUTO ; override serverurl computation (childutils)
118
+
119
+ ; The sample eventlistener section below shows all possible eventlistener
120
+ ; subsection values. Create one or more 'real' eventlistener: sections to be
121
+ ; able to handle event notifications sent by supervisord.
122
+
123
+ ;[eventlistener:theeventlistenername]
124
+ ;command=/bin/eventlistener ; the program (relative uses PATH, can take args)
125
+ ;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
126
+ ;numprocs=1 ; number of processes copies to start (def 1)
127
+ ;events=EVENT ; event notif. types to subscribe to (req'd)
128
+ ;buffer_size=10 ; event buffer queue size (default 10)
129
+ ;directory=/tmp ; directory to cwd to before exec (def no cwd)
130
+ ;umask=022 ; umask for process (default None)
131
+ ;priority=-1 ; the relative start priority (default -1)
132
+ ;autostart=true ; start at supervisord start (default: true)
133
+ ;startsecs=1 ; # of secs prog must stay up to be running (def. 1)
134
+ ;startretries=3 ; max # of serial start failures when starting (default 3)
135
+ ;autorestart=unexpected ; autorestart if exited after running (def: unexpected)
136
+ ;exitcodes=0 ; 'expected' exit codes used with autorestart (default 0)
137
+ ;stopsignal=QUIT ; signal used to kill process (default TERM)
138
+ ;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
139
+ ;stopasgroup=false ; send stop signal to the UNIX process group (default false)
140
+ ;killasgroup=false ; SIGKILL the UNIX process group (def false)
141
+ ;user=chrism ; setuid to this UNIX account to run the program
142
+ ;redirect_stderr=false ; redirect_stderr=true is not allowed for eventlisteners
143
+ ;stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO
144
+ ;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
145
+ ;stdout_logfile_backups=10 ; # of stdout logfile backups (0 means none, default 10)
146
+ ;stdout_events_enabled=false ; emit events on stdout writes (default false)
147
+ ;stdout_syslog=false ; send stdout to syslog with process name (default false)
148
+ ;stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO
149
+ ;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
150
+ ;stderr_logfile_backups=10 ; # of stderr logfile backups (0 means none, default 10)
151
+ ;stderr_events_enabled=false ; emit events on stderr writes (default false)
152
+ ;stderr_syslog=false ; send stderr to syslog with process name (default false)
153
+ ;environment=A="1",B="2" ; process environment additions
154
+ ;serverurl=AUTO ; override serverurl computation (childutils)
155
+
156
+ ; The sample group section below shows all possible group values. Create one
157
+ ; or more 'real' group: sections to create "heterogeneous" process groups.
158
+
159
+ ;[group:thegroupname]
160
+ ;programs=progname1,progname2 ; each refers to 'x' in [program:x] definitions
161
+ ;priority=999 ; the relative start priority (default 999)
162
+
163
+ ; The [include] section can just contain the "files" setting. This
164
+ ; setting can list multiple files (separated by whitespace or
165
+ ; newlines). It can also contain wildcards. The filenames are
166
+ ; interpreted as relative to this file. Included files *cannot*
167
+ ; include files themselves.
168
+
169
+ ;[include]
170
+ ;files = relative/directory/*.ini
171
+
172
+ [include]
173
+ files = /darkchats/funbuild/conf/*.ini
174
+
@@ -0,0 +1,5 @@
1
+ """
2
+ 执行shell
3
+ """
4
+ from .core import run_shell
5
+ from.core import run_shell_list
@@ -0,0 +1,36 @@
1
+ import subprocess
2
+ import sys
3
+ from typing import List
4
+
5
+
6
+ def run_shell(command: str, printf=True) -> str:
7
+ """
8
+ 执行shell命令
9
+ """
10
+ if printf:
11
+ try:
12
+ cmd = subprocess.Popen(command, stdin=subprocess.PIPE, stderr=sys.stderr, close_fds=True,
13
+ stdout=sys.stdout, universal_newlines=True, shell=True, bufsize=1)
14
+ cmd.communicate()
15
+ return cmd.returncode
16
+ except Exception as e:
17
+ return f"run shell error:{e}"
18
+ else:
19
+ try:
20
+ outputs = subprocess.Popen(
21
+ command, stdout=subprocess.PIPE, shell=True).communicate()
22
+ outputs = [i.decode('utf-8')[:-1] for i in outputs if i is not None]
23
+ outputs = [i for i in outputs if len(i.strip()) > 0]
24
+ return ''.join(outputs)
25
+ except Exception as e:
26
+ return f"run shell error:{e}"
27
+
28
+
29
+ def run_shell_list(command_list: List[str], printf=True) -> str:
30
+ """
31
+ 批量执行shell命令
32
+ """
33
+ # for shell in shell_list:
34
+ # run_shell(shell, printf=printf)
35
+ command = ' && '.join(command_list)
36
+ return run_shell(command, printf=printf)
File without changes
@@ -0,0 +1,6 @@
1
+ {
2
+ "a": "v",
3
+
4
+
5
+ "d": 3
6
+ }
File without changes
@@ -0,0 +1 @@
1
+ from .build import read_version
@@ -0,0 +1,7 @@
1
+ from funbuild.core.version import VersionManage
2
+
3
+
4
+ def read_version(version_path):
5
+ manage = VersionManage(version_path)
6
+ manage.read()
7
+ return manage.version
@@ -0,0 +1,33 @@
1
+ from functools import wraps
2
+
3
+ _api_routes_registry = []
4
+
5
+
6
+ class api_route(object):
7
+ def __init__(self, path, **kwargs):
8
+ self._path = path
9
+ self._kwargs = kwargs
10
+
11
+ def __call__(self, fn):
12
+ cls, method = fn.__repr__().split(" ")[1].split(".")
13
+ _api_routes_registry.append(
14
+ {
15
+ "fn": fn,
16
+ "path": self._path,
17
+ "kwargs": self._kwargs,
18
+ "cls": cls,
19
+ "method": method,
20
+ }
21
+ )
22
+
23
+ @wraps(fn)
24
+ def decorated(*args, **kwargs):
25
+ return fn(*args, **kwargs)
26
+
27
+ return decorated
28
+
29
+
30
+ def add_api_routes(router):
31
+ for reg in _api_routes_registry:
32
+ if router.__class__.__name__ == reg["cls"]:
33
+ router.add_api_route(path=reg["path"], endpoint=getattr(router, reg["method"]), **reg["kwargs"])
@@ -0,0 +1,8 @@
1
+ Metadata-Version: 2.1
2
+ Name: funbuild
3
+ Version: 202306301655
4
+ Summary: funbuild
5
+ Home-page: https://github.com/1007530194
6
+ Author: bingtao
7
+ Author-email: 1007530194@qq.com
8
+ License-File: LICENSE
@@ -0,0 +1,27 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ funbuild/__init__.py
5
+ funbuild.egg-info/PKG-INFO
6
+ funbuild.egg-info/SOURCES.txt
7
+ funbuild.egg-info/dependency_links.txt
8
+ funbuild.egg-info/entry_points.txt
9
+ funbuild.egg-info/requires.txt
10
+ funbuild.egg-info/top_level.txt
11
+ funbuild/core/__init__.py
12
+ funbuild/core/core.py
13
+ funbuild/core/version.py
14
+ funbuild/git/__init__.py
15
+ funbuild/git/repo.py
16
+ funbuild/manage/__init__.py
17
+ funbuild/manage/core.py
18
+ funbuild/manage/port.md
19
+ funbuild/manage/supervisord.conf
20
+ funbuild/shell/__init__.py
21
+ funbuild/shell/core.py
22
+ funbuild/temp/__init__.py
23
+ funbuild/temp/core.json
24
+ funbuild/temp/core.py
25
+ funbuild/tool/__init__.py
26
+ funbuild/tool/build.py
27
+ funbuild/tool/fastapi.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ funbuild = funbuild.core:funbuild
@@ -0,0 +1 @@
1
+ GitPython
@@ -0,0 +1 @@
1
+ funbuild
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,20 @@
1
+ import sys
2
+ from os import path
3
+ import time
4
+ from setuptools import find_packages, setup
5
+
6
+
7
+ install_requires = ['GitPython']
8
+
9
+ setup(name='funbuild',
10
+ version=time.strftime("%Y%m%d%H%M", time.localtime()),
11
+ description='funbuild',
12
+ author='bingtao',
13
+ author_email='1007530194@qq.com',
14
+ url='https://github.com/1007530194',
15
+ packages=find_packages(),
16
+ package_data={"": ["*.js", "*.*"]},
17
+ entry_points={'console_scripts': [
18
+ 'funbuild = funbuild.core:funbuild', ]},
19
+ install_requires=install_requires,
20
+ )