ConsoleFramework 2.0.0__tar.gz → 2.0.2__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.
@@ -10,7 +10,7 @@ import time
10
10
  import math
11
11
  import random
12
12
  import socket
13
- import requests
13
+ import urllib.request
14
14
  import json
15
15
  import threading
16
16
  import platform
@@ -18,7 +18,7 @@ import zipfile
18
18
  import stat
19
19
  import subprocess as CMD
20
20
  import threading
21
-
21
+ import urllib.request
22
22
  class Colors:
23
23
  RESET = "\033[0m"
24
24
  RED = "\033[31m"
@@ -395,6 +395,7 @@ class ConsoleInfo:
395
395
  return result.stdout.strip()
396
396
  except:
397
397
  return "Error: pip not found"
398
+
398
399
  class Process:
399
400
  @staticmethod
400
401
  def StartPyCode(code, wait=False, args=None, python="python"):
@@ -501,142 +502,27 @@ class Process:
501
502
  @staticmethod
502
503
  def GetCurrentPID():
503
504
  return os.getpid()
505
+
504
506
  class Channel:
505
507
  def __init__(self):
506
508
  self.connection = None
507
509
  self.host = None
508
510
  self.port = None
509
511
  self.is_server = False
510
- self.ngrok_process = None
511
- self.ngrok_url = None
512
- self.renew_thread = None
513
- self.renew_active = False
514
512
 
515
513
  @staticmethod
516
- def GetPublicIP():
514
+ def _get(url, timeout=5):
517
515
  try:
518
- return requests.get('https://api.ipify.org', timeout=5).text
516
+ import urllib.request
517
+ with urllib.request.urlopen(url, timeout=timeout) as response:
518
+ return response.read().decode()
519
519
  except Exception:
520
520
  return None
521
521
 
522
522
  @staticmethod
523
- def DownloadNgrok():
524
- system = platform.system().lower()
525
- arch = platform.machine().lower()
526
-
527
- if system == 'windows':
528
- url = 'https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-windows-amd64.zip'
529
- exe_name = 'ngrok.exe'
530
- elif system == 'linux':
531
- if 'aarch64' in arch or 'arm64' in arch:
532
- url = 'https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm64.zip'
533
- else:
534
- url = 'https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip'
535
- exe_name = 'ngrok'
536
- elif system == 'darwin':
537
- url = 'https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-darwin-amd64.zip'
538
- exe_name = 'ngrok'
539
- else:
540
- print(f"[Error] Unsupported platform: {system}")
541
- return False
542
-
543
- if os.path.exists(exe_name):
544
- return True
545
-
546
- print(f"[Ngrok] Downloading from {url}...")
547
- try:
548
- response = requests.get(url, stream=True)
549
- with open('ngrok.zip', 'wb') as f:
550
- for chunk in response.iter_content(chunk_size=8192):
551
- f.write(chunk)
552
-
553
- with zipfile.ZipFile('ngrok.zip', 'r') as zip_ref:
554
- zip_ref.extractall('.')
555
-
556
- os.remove('ngrok.zip')
557
-
558
- if system != 'windows':
559
- st = os.stat(exe_name)
560
- os.chmod(exe_name, st.st_mode | stat.S_IEXEC)
561
-
562
- print(f"[Ngrok] Downloaded successfully!")
563
- return True
564
- except Exception as e:
565
- print(f"[Error] Failed to download ngrok: {e}")
566
- return False
567
-
568
- def CreateNgrokTunnel(self, port=54321, region='us'):
569
- if not os.path.exists('ngrok') and not os.path.exists('ngrok.exe'):
570
- print("[Ngrok] ngrok not found. Downloading...")
571
- if not self.DownloadNgrok():
572
- return None
573
-
574
- try:
575
- exe_name = 'ngrok.exe' if platform.system().lower() == 'windows' else 'ngrok'
576
-
577
- cmd = f"./{exe_name} tcp {port} --region={region} --log=stdout --log-level=info"
578
- if platform.system().lower() == 'windows':
579
- cmd = f"{exe_name} tcp {port} --region={region} --log=stdout --log-level=info"
580
-
581
- self.ngrok_process = CMD.Popen(cmd, shell=True, stdout=CMD.PIPE, stderr=CMD.PIPE)
582
- time.sleep(3)
583
-
584
- response = requests.get('http://localhost:4040/api/tunnels')
585
- data = response.json()
586
- if data['tunnels']:
587
- self.ngrok_url = data['tunnels'][0]['public_url']
588
- print(f"[Ngrok] Tunnel created: {self.ngrok_url}")
589
- return self.ngrok_url
590
- else:
591
- print("[Ngrok] No tunnels found")
592
- return None
593
- except Exception as e:
594
- print(f"[Ngrok] Error: {e}")
595
- return None
596
-
597
- def StopNgrokTunnel(self):
598
- if self.ngrok_process:
599
- self.ngrok_process.terminate()
600
- self.ngrok_process = None
601
- self.ngrok_url = None
602
- print("[Ngrok] Tunnel stopped")
603
-
604
- def _renew_loop(self, port, region, interval):
605
- while self.renew_active:
606
- time.sleep(interval)
607
- self.StopNgrokTunnel()
608
- self.CreateNgrokTunnel(port, region)
609
- print("[Ngrok] Tunnel renewed")
610
-
611
- def StartAutoRenew(self, port=54321, region='us', interval=7000):
612
- self.renew_active = True
613
- self.renew_thread = threading.Thread(target=self._renew_loop, args=(port, region, interval))
614
- self.renew_thread.daemon = True
615
- self.renew_thread.start()
616
-
617
- def StopAutoRenew(self):
618
- self.renew_active = False
619
- if self.renew_thread:
620
- self.renew_thread.join(timeout=1)
621
-
622
- def CreateServer(self, port=54321, ngrok=False, region='us', auto_renew=False, renew_interval=7000):
623
- self.is_server = True
624
- self.port = port
625
-
626
- if ngrok:
627
- self.CreateNgrokTunnel(port, region)
628
- if auto_renew:
629
- self.StartAutoRenew(port, region, renew_interval)
630
-
631
- try:
632
- server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
633
- server.bind(('0.0.0.0', port))
634
- server.listen(1)
635
- self.connection, addr = server.accept()
636
- return self.connection
637
- except Exception as e:
638
- print(f"[Error] Server failed: {e}")
639
- return None
523
+ def GetPublicIP():
524
+ ip = Channel._get('https://api.ipify.org')
525
+ return ip
640
526
 
641
527
  def Connect(self, host='127.0.0.1', port=54321):
642
528
  self.host = host
@@ -656,12 +542,23 @@ class Channel:
656
542
  return None
657
543
  return self.Connect(host=public_ip, port=port)
658
544
 
545
+ def CreateServer(self, port=54321):
546
+ self.is_server = True
547
+ self.port = port
548
+ try:
549
+ server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
550
+ server.bind(('0.0.0.0', port))
551
+ server.listen(1)
552
+ self.connection, addr = server.accept()
553
+ return self.connection
554
+ except Exception as e:
555
+ print(f"[Error] Server failed: {e}")
556
+ return None
557
+
659
558
  def Disconnect(self):
660
559
  if self.connection:
661
560
  self.connection.close()
662
561
  self.connection = None
663
- if self.ngrok_process:
664
- self.StopNgrokTunnel()
665
562
 
666
563
  def Send(self, message):
667
564
  if not self.connection:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ConsoleFramework
3
- Version: 2.0.0
3
+ Version: 2.0.2
4
4
  Summary: The best Console Library of the Python.
5
5
  Author: Suleiman
6
6
  Author-email: steal.apet@mail.ru
@@ -10,13 +10,15 @@ Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
11
11
  Requires-Python: >=3.6
12
12
  Description-Content-Type: text/plain
13
+ License-File: LICENSE
13
14
  Dynamic: author
14
15
  Dynamic: author-email
15
16
  Dynamic: classifier
16
17
  Dynamic: description
17
18
  Dynamic: description-content-type
18
19
  Dynamic: license
20
+ Dynamic: license-file
19
21
  Dynamic: requires-python
20
22
  Dynamic: summary
21
23
 
22
- ConsoleFramework - Pure Python library for console rendering, animations, processes and more.
24
+ ConsoleFramework - Pure Python library for console rendering, animations, processes and more. In this module ONLY standart python, no other modules.
@@ -1,3 +1,4 @@
1
+ LICENSE
1
2
  MANIFEST.in
2
3
  setup.py
3
4
  ConsoleFramework/__init__.py
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Suleiman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ConsoleFramework
3
- Version: 2.0.0
3
+ Version: 2.0.2
4
4
  Summary: The best Console Library of the Python.
5
5
  Author: Suleiman
6
6
  Author-email: steal.apet@mail.ru
@@ -10,13 +10,15 @@ Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
11
11
  Requires-Python: >=3.6
12
12
  Description-Content-Type: text/plain
13
+ License-File: LICENSE
13
14
  Dynamic: author
14
15
  Dynamic: author-email
15
16
  Dynamic: classifier
16
17
  Dynamic: description
17
18
  Dynamic: description-content-type
18
19
  Dynamic: license
20
+ Dynamic: license-file
19
21
  Dynamic: requires-python
20
22
  Dynamic: summary
21
23
 
22
- ConsoleFramework - Pure Python library for console rendering, animations, processes and more.
24
+ ConsoleFramework - Pure Python library for console rendering, animations, processes and more. In this module ONLY standart python, no other modules.
@@ -2,9 +2,9 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="ConsoleFramework",
5
- version="2.0.0",
5
+ version="2.0.2",
6
6
  description="The best Console Library of the Python.",
7
- long_description="ConsoleFramework - Pure Python library for console rendering, animations, processes and more.",
7
+ long_description="ConsoleFramework - Pure Python library for console rendering, animations, processes and more. In this module ONLY standart python, no other modules.",
8
8
  long_description_content_type="text/plain",
9
9
  author="Suleiman",
10
10
  author_email="steal.apet@mail.ru",