orrin-cli 0.3.0b3__tar.gz → 0.3.0b4__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: orrin-cli
3
- Version: 0.3.0b3
3
+ Version: 0.3.0b4
4
4
  Summary: Orrin CLI
5
5
  Requires-Python: >=3.9
6
6
  Description-Content-Type: text/markdown
@@ -13,4 +13,4 @@ Dynamic: license-file
13
13
 
14
14
  ## What's New
15
15
 
16
- In v0.3.0b3, we introduce the ability to mount custom handlers to Terminal Sessions, start mounted handlers, and unmount handlers.
16
+ In v0.3.0b4, we introduce support for creating "mounts" for websocket connectivity with our newly released Exegesis Specification for Interactivity.
@@ -0,0 +1,5 @@
1
+ # Orrin CLI v0.3.0b3
2
+
3
+ ## What's New
4
+
5
+ In v0.3.0b4, we introduce support for creating "mounts" for websocket connectivity with our newly released Exegesis Specification for Interactivity.
@@ -14,6 +14,8 @@ import asyncio
14
14
  import importlib.util
15
15
  import sys
16
16
  from pathlib import Path
17
+ from urllib.parse import urlparse
18
+ import ipaddress
17
19
 
18
20
  app = typer.Typer(help="""
19
21
  Welcome to Orrin CLI v0.1.9!\n\n
@@ -36,6 +38,9 @@ app.add_typer(projects, name='projects')
36
38
  sessions = typer.Typer(help='Terminal Sessions enabling projects to be created in your terminal env from iOS and Web app')
37
39
  app.add_typer(sessions, name='sessions')
38
40
 
41
+ especi = typer.Typer(help='Exegesis Specification for Interactivity (ESPECI) configurations')
42
+ app.add_typer(especi, name='especi')
43
+
39
44
  API_BASE = "https://stellr-company.com"
40
45
 
41
46
  APP_NAME = "orrin"
@@ -45,6 +50,7 @@ config_dir = Path(user_config_dir(APP_NAME, APP_AUTHOR))
45
50
  config_dir.mkdir(parents=True, exist_ok=True)
46
51
 
47
52
  config_file = config_dir / "config.json"
53
+ print(config_file)
48
54
 
49
55
  # ---- Configuration based commands/helper functions ----
50
56
 
@@ -1613,6 +1619,191 @@ def show():
1613
1619
 
1614
1620
  # ---------------------------
1615
1621
 
1622
+ def is_development_url(url: str) -> bool:
1623
+ parsed = urlparse(url)
1624
+ host = parsed.hostname
1625
+
1626
+ if host is None:
1627
+ return False
1628
+
1629
+ # Common localhost names
1630
+ if host.lower() in {
1631
+ "localhost",
1632
+ "localhost.localdomain",
1633
+ }:
1634
+ return True
1635
+
1636
+ try:
1637
+ ip = ipaddress.ip_address(host)
1638
+
1639
+ # Loopback: 127.0.0.0/8, ::1
1640
+ if ip.is_loopback:
1641
+ return True
1642
+
1643
+ # Private networks: 10.x, 172.16-31.x, 192.168.x
1644
+ if ip.is_private:
1645
+ return True
1646
+
1647
+ # Link-local: 169.254.x.x
1648
+ if ip.is_link_local:
1649
+ return True
1650
+
1651
+ except ValueError:
1652
+ # Not an IP address
1653
+ pass
1654
+
1655
+ return False
1656
+
1657
+ @especi.command(help='Create a mount for your webpage to use to enable websocket-based dynamic adaptability')
1658
+ def cmount():
1659
+ config = load_config()
1660
+
1661
+ if config is None or not 'api_key' in config:
1662
+ typer.echo('\nYou have not configured a developer API. Please run:')
1663
+ typer.echo('\t' + typer.style(' orrin config configure-dev ', fg=typer.colors.YELLOW) + '\n')
1664
+ return
1665
+
1666
+ url = typer.prompt('Production URL')
1667
+
1668
+ while is_development_url(url):
1669
+ typer.echo(
1670
+ typer.style(
1671
+ f'Invalid URL. A production URL is required.',
1672
+ fg=typer.colors.RED
1673
+ )
1674
+ )
1675
+
1676
+ url = typer.prompt('Production URL')
1677
+
1678
+ r = requests.post(
1679
+ 'http://192.168.1.96:8081/v1/create_especi_mount',
1680
+ headers={ 'fsdk': 'yes', 'authorization': config['api_key'] },
1681
+ json={
1682
+ 'url': url
1683
+ }
1684
+ )
1685
+
1686
+ if r.ok:
1687
+ typer.echo(
1688
+ '\n' + typer.style(
1689
+ f'ESPECI mount for {url} created.',
1690
+ fg=typer.colors.GREEN
1691
+ ) + '\n'
1692
+ )
1693
+
1694
+ r = r.json()
1695
+
1696
+ typer.echo(f'Mount ID: {r["mount_id"]}')
1697
+
1698
+ if 'especi_mounts' in config:
1699
+ config['especi_mounts'].append({
1700
+ 'url': url,
1701
+ 'mount_id': r['mount_id']
1702
+ })
1703
+ else:
1704
+ config['especi_mounts'] = [{
1705
+ 'url': url,
1706
+ 'mount_id': r['mount_id']
1707
+ }]
1708
+
1709
+ write_config(config)
1710
+ else:
1711
+ try:
1712
+ r = r.json()
1713
+
1714
+ if r['message'] == 'url_mount_exists':
1715
+ typer.echo(
1716
+ '\n' + typer.style(
1717
+ f'Failed to create ESPECI mount: mount exists for {url}.',
1718
+ fg=typer.colors.RED
1719
+ )
1720
+ )
1721
+ return
1722
+
1723
+ raise Exception
1724
+ except:
1725
+ typer.echo(
1726
+ '\n' + typer.style(
1727
+ f'Failed to create ESPECI mount.',
1728
+ fg=typer.colors.RED
1729
+ )
1730
+ )
1731
+
1732
+ @especi.command(help='Create a mount for your webpage that runs on local addresses to use to enable websocket-based dynamic adaptability')
1733
+ def cmount_dev():
1734
+ config = load_config()
1735
+
1736
+ if config is None or not 'api_key' in config:
1737
+ typer.echo('\nYou have not configured a developer API. Please run:')
1738
+ typer.echo('\t' + typer.style(' orrin config configure-dev ', fg=typer.colors.YELLOW) + '\n')
1739
+ return
1740
+
1741
+ url = typer.prompt('Development URL')
1742
+
1743
+ while not is_development_url(url):
1744
+ typer.echo(
1745
+ typer.style(
1746
+ f'Invalid URL. A production URL is required.',
1747
+ fg=typer.colors.RED
1748
+ )
1749
+ )
1750
+
1751
+ url = typer.prompt('Production URL')
1752
+
1753
+ r = requests.post(
1754
+ 'http://192.168.1.96:8081/v1/create_especi_mount',
1755
+ headers={ 'fsdk': 'yes', 'authorization': config['api_key'] },
1756
+ json={
1757
+ 'url': url
1758
+ }
1759
+ )
1760
+
1761
+ if r.ok:
1762
+ typer.echo(
1763
+ '\n' + typer.style(
1764
+ f'ESPECI mount for {url} created.',
1765
+ fg=typer.colors.GREEN
1766
+ ) + '\n'
1767
+ )
1768
+
1769
+ r = r.json()
1770
+
1771
+ typer.echo(f'Mount ID: {r["mount_id"]}')
1772
+
1773
+ if 'especi_mounts' in config:
1774
+ config['especi_mounts'].append({
1775
+ 'url': url,
1776
+ 'mount_id': r['mount_id']
1777
+ })
1778
+ else:
1779
+ config['especi_mounts'] = [{
1780
+ 'url': url,
1781
+ 'mount_id': r['mount_id']
1782
+ }]
1783
+
1784
+ write_config(config)
1785
+ else:
1786
+ try:
1787
+ r = r.json()
1788
+
1789
+ if r['message'] == 'url_mount_exists':
1790
+ typer.echo(
1791
+ '\n' + typer.style(
1792
+ f'Failed to create ESPECI mount: mount exists for {url}.',
1793
+ fg=typer.colors.RED
1794
+ )
1795
+ )
1796
+ return
1797
+
1798
+ raise Exception
1799
+ except:
1800
+ typer.echo(
1801
+ '\n' + typer.style(
1802
+ f'Failed to create ESPECI mount.',
1803
+ fg=typer.colors.RED
1804
+ )
1805
+ )
1806
+
1616
1807
  def main():
1617
1808
  app()
1618
1809
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: orrin-cli
3
- Version: 0.3.0b3
3
+ Version: 0.3.0b4
4
4
  Summary: Orrin CLI
5
5
  Requires-Python: >=3.9
6
6
  Description-Content-Type: text/markdown
@@ -13,4 +13,4 @@ Dynamic: license-file
13
13
 
14
14
  ## What's New
15
15
 
16
- In v0.3.0b3, we introduce the ability to mount custom handlers to Terminal Sessions, start mounted handlers, and unmount handlers.
16
+ In v0.3.0b4, we introduce support for creating "mounts" for websocket connectivity with our newly released Exegesis Specification for Interactivity.
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "orrin-cli"
3
3
  readme = "README.md"
4
- version = "0.3.0b3"
4
+ version = "0.3.0b4"
5
5
  description = "Orrin CLI"
6
6
  requires-python = ">=3.9"
7
7
  dependencies = [
@@ -1,5 +0,0 @@
1
- # Orrin CLI v0.3.0b3
2
-
3
- ## What's New
4
-
5
- In v0.3.0b3, we introduce the ability to mount custom handlers to Terminal Sessions, start mounted handlers, and unmount handlers.
File without changes
File without changes