orrin-cli 0.3.0b3__tar.gz → 0.3.0b5__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.0b5
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"
@@ -1613,6 +1618,191 @@ def show():
1613
1618
 
1614
1619
  # ---------------------------
1615
1620
 
1621
+ def is_development_url(url: str) -> bool:
1622
+ parsed = urlparse(url)
1623
+ host = parsed.hostname
1624
+
1625
+ if host is None:
1626
+ return False
1627
+
1628
+ # Common localhost names
1629
+ if host.lower() in {
1630
+ "localhost",
1631
+ "localhost.localdomain",
1632
+ }:
1633
+ return True
1634
+
1635
+ try:
1636
+ ip = ipaddress.ip_address(host)
1637
+
1638
+ # Loopback: 127.0.0.0/8, ::1
1639
+ if ip.is_loopback:
1640
+ return True
1641
+
1642
+ # Private networks: 10.x, 172.16-31.x, 192.168.x
1643
+ if ip.is_private:
1644
+ return True
1645
+
1646
+ # Link-local: 169.254.x.x
1647
+ if ip.is_link_local:
1648
+ return True
1649
+
1650
+ except ValueError:
1651
+ # Not an IP address
1652
+ pass
1653
+
1654
+ return False
1655
+
1656
+ @especi.command(help='Create a mount for your webpage to use to enable websocket-based dynamic adaptability')
1657
+ def cmount():
1658
+ config = load_config()
1659
+
1660
+ if config is None or not 'api_key' in config:
1661
+ typer.echo('\nYou have not configured a developer API. Please run:')
1662
+ typer.echo('\t' + typer.style(' orrin config configure-dev ', fg=typer.colors.YELLOW) + '\n')
1663
+ return
1664
+
1665
+ url = typer.prompt('Production URL')
1666
+
1667
+ while is_development_url(url):
1668
+ typer.echo(
1669
+ typer.style(
1670
+ f'Invalid URL. A production URL is required.',
1671
+ fg=typer.colors.RED
1672
+ )
1673
+ )
1674
+
1675
+ url = typer.prompt('Production URL')
1676
+
1677
+ r = requests.post(
1678
+ 'http://192.168.1.96:8081/v1/create_especi_mount',
1679
+ headers={ 'fsdk': 'yes', 'authorization': config['api_key'] },
1680
+ json={
1681
+ 'url': url
1682
+ }
1683
+ )
1684
+
1685
+ if r.ok:
1686
+ typer.echo(
1687
+ '\n' + typer.style(
1688
+ f'ESPECI mount for {url} created.',
1689
+ fg=typer.colors.GREEN
1690
+ ) + '\n'
1691
+ )
1692
+
1693
+ r = r.json()
1694
+
1695
+ typer.echo(f'Mount ID: {r["mount_id"]}')
1696
+
1697
+ if 'especi_mounts' in config:
1698
+ config['especi_mounts'].append({
1699
+ 'url': url,
1700
+ 'mount_id': r['mount_id']
1701
+ })
1702
+ else:
1703
+ config['especi_mounts'] = [{
1704
+ 'url': url,
1705
+ 'mount_id': r['mount_id']
1706
+ }]
1707
+
1708
+ write_config(config)
1709
+ else:
1710
+ try:
1711
+ r = r.json()
1712
+
1713
+ if r['message'] == 'url_mount_exists':
1714
+ typer.echo(
1715
+ '\n' + typer.style(
1716
+ f'Failed to create ESPECI mount: mount exists for {url}.',
1717
+ fg=typer.colors.RED
1718
+ )
1719
+ )
1720
+ return
1721
+
1722
+ raise Exception
1723
+ except:
1724
+ typer.echo(
1725
+ '\n' + typer.style(
1726
+ f'Failed to create ESPECI mount.',
1727
+ fg=typer.colors.RED
1728
+ )
1729
+ )
1730
+
1731
+ @especi.command(help='Create a mount for your webpage that runs on local addresses to use to enable websocket-based dynamic adaptability')
1732
+ def cmount_dev():
1733
+ config = load_config()
1734
+
1735
+ if config is None or not 'api_key' in config:
1736
+ typer.echo('\nYou have not configured a developer API. Please run:')
1737
+ typer.echo('\t' + typer.style(' orrin config configure-dev ', fg=typer.colors.YELLOW) + '\n')
1738
+ return
1739
+
1740
+ url = typer.prompt('Development URL')
1741
+
1742
+ while not is_development_url(url):
1743
+ typer.echo(
1744
+ typer.style(
1745
+ f'Invalid URL. A production URL is required.',
1746
+ fg=typer.colors.RED
1747
+ )
1748
+ )
1749
+
1750
+ url = typer.prompt('Production URL')
1751
+
1752
+ r = requests.post(
1753
+ 'http://192.168.1.96:8081/v1/create_especi_mount',
1754
+ headers={ 'fsdk': 'yes', 'authorization': config['api_key'] },
1755
+ json={
1756
+ 'url': url
1757
+ }
1758
+ )
1759
+
1760
+ if r.ok:
1761
+ typer.echo(
1762
+ '\n' + typer.style(
1763
+ f'ESPECI mount for {url} created.',
1764
+ fg=typer.colors.GREEN
1765
+ ) + '\n'
1766
+ )
1767
+
1768
+ r = r.json()
1769
+
1770
+ typer.echo(f'Mount ID: {r["mount_id"]}')
1771
+
1772
+ if 'especi_mounts' in config:
1773
+ config['especi_mounts'].append({
1774
+ 'url': url,
1775
+ 'mount_id': r['mount_id']
1776
+ })
1777
+ else:
1778
+ config['especi_mounts'] = [{
1779
+ 'url': url,
1780
+ 'mount_id': r['mount_id']
1781
+ }]
1782
+
1783
+ write_config(config)
1784
+ else:
1785
+ try:
1786
+ r = r.json()
1787
+
1788
+ if r['message'] == 'url_mount_exists':
1789
+ typer.echo(
1790
+ '\n' + typer.style(
1791
+ f'Failed to create ESPECI mount: mount exists for {url}.',
1792
+ fg=typer.colors.RED
1793
+ )
1794
+ )
1795
+ return
1796
+
1797
+ raise Exception
1798
+ except:
1799
+ typer.echo(
1800
+ '\n' + typer.style(
1801
+ f'Failed to create ESPECI mount.',
1802
+ fg=typer.colors.RED
1803
+ )
1804
+ )
1805
+
1616
1806
  def main():
1617
1807
  app()
1618
1808
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: orrin-cli
3
- Version: 0.3.0b3
3
+ Version: 0.3.0b5
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.0b5"
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