millistream-mdf 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,42 @@
1
+ """
2
+ Python wrapper for libmdf C SDK.
3
+
4
+ This package provides a high-level, intuitive Python API for connecting to
5
+ Millistream Data Feed servers and consuming real-time financial data.
6
+
7
+ Example:
8
+ from millistream_mdf import MDF
9
+
10
+ with MDF(url='server:port', username='user', password='pass') as session:
11
+ for message in session.subscribe(message_classes=['quote', 'trade'], insrefs='*'):
12
+ print(f"{message.type}: {message.fields}")
13
+ """
14
+
15
+ from .sync_client import MDF
16
+ from .async_client import AsyncMDF
17
+ from .message_builder import MessageBuilder
18
+ from .message import Message
19
+ from .exceptions import (
20
+ MDFError,
21
+ MDFConnectionError,
22
+ MDFAuthenticationError,
23
+ MDFTimeoutError,
24
+ MDFMessageError,
25
+ MDFConfigurationError,
26
+ MDFLibraryError,
27
+ )
28
+ from ._constants import (
29
+ # Main enums for user API
30
+ MessageReference,
31
+ Field,
32
+ RequestClass,
33
+ RequestType
34
+ )
35
+
36
+ __version__ = "0.1.0"
37
+ __author__ = "Gustav Frison"
38
+ __email__ = "gustav.frison@millistream.com"
39
+
40
+ __all__ = [
41
+ 'MDF', 'MDFAsync', 'RequestType', 'RequestClass', 'MessageReference', 'Field', 'BatchItem'
42
+ ]
@@ -0,0 +1,131 @@
1
+ import argparse
2
+ import subprocess
3
+ import sys
4
+
5
+ from rich.console import Console
6
+ from rich.panel import Panel
7
+
8
+ from millistream_mdf import __version__
9
+
10
+ console = Console()
11
+
12
+
13
+
14
+
15
+ def install_linux() -> None:
16
+ """Install libmdf for Linux"""
17
+ console.print(Panel(
18
+ f"Installing libmdf for [bold]Linux[/bold]...\n\n"
19
+ f"This will automatically install the necessary dependency 'libmdf' using apt package manager."
20
+ ))
21
+
22
+ try:
23
+ # Step 1: Update package list and install prerequisites
24
+ console.print("[bold]Step 1:[/bold] Updating package list and installing prerequisites...")
25
+ subprocess.run(["apt", "update"], check=True)
26
+ subprocess.run(["apt", "install", "-y", "lsb-release", "wget", "gpg"], check=True)
27
+
28
+ # Step 2: Add Millistream repository
29
+ console.print("[bold]Step 2:[/bold] Adding Millistream repository...")
30
+
31
+ # Get the distribution codename
32
+ result = subprocess.run(["lsb_release", "-cs"], capture_output=True, text=True, check=True)
33
+ codename = result.stdout.strip()
34
+
35
+ # Download and add the repository
36
+ repo_url = f"https://packages.millistream.com/apt/sources.list.d/{codename}.list"
37
+ subprocess.run(["wget", repo_url, "-O", "/etc/apt/sources.list.d/millistream.list"], check=True)
38
+
39
+ # Add the GPG key
40
+ console.print("[bold]Step 3b:[/bold] Adding GPG key...")
41
+ subprocess.run(
42
+ 'wget -O- "https://packages.millistream.com/D2FCCE35.gpg" | gpg --dearmor | tee /usr/share/keyrings/millistream-archive-keyring.gpg > /dev/null',
43
+ shell=True,
44
+ check=True
45
+ )
46
+
47
+ # Step 3: Install libmdf
48
+ console.print("[bold]Step 4:[/bold] Installing libmdf...")
49
+ subprocess.run(["apt", "update"], check=True)
50
+ subprocess.run(["apt", "install", "-y", "libmdf"], check=True)
51
+
52
+ console.print(Panel(
53
+ f"[bold green]✅ Installation completed successfully![/bold green]\n\n"
54
+ f"libmdf has been installed and is ready to use.\n\n"
55
+ f"For more information, visit: [blue link=https://github.com/mint273/millistream-mdf]https://github.com/mint273/millistream-mdf[/blue link]"
56
+ ))
57
+
58
+ except subprocess.CalledProcessError as e:
59
+ console.print(Panel(
60
+ f"[bold red]❌ Installation failed![/bold red]\n\n"
61
+ f"Error: {e}\n\n"
62
+ f"Please try running the installation manually or check your system permissions.\n\n"
63
+ f"For manual installation instructions, visit: [blue link=https://github.com/mint273/millistream-mdf]https://github.com/mint273/millistream-mdf[/blue link]"
64
+ ))
65
+ sys.exit(1)
66
+ except FileNotFoundError:
67
+ console.print(Panel(
68
+ f"[bold red]❌ Installation failed![/bold red]\n\n"
69
+ f"Required system tools not found. Please ensure you have 'sudo', 'apt', 'wget', and 'gpg' installed.\n\n"
70
+ f"For manual installation instructions, visit: [blue link=https://github.com/mint273/millistream-mdf]https://github.com/mint273/millistream-mdf[/blue link]"
71
+ ))
72
+ sys.exit(1)
73
+
74
+
75
+
76
+ def install_macos() -> None:
77
+ """Install libmdf for macOS"""
78
+ console.print(Panel(
79
+ f"Installation notice for [bold]macOS[/bold]:\n\n"
80
+ f"For [bold]macOS[/bold], it's recommended to install the necessary dependency 'libmdf' using the [bold].pkg[/bold] installer from [blue link=https://packages.millistream.com/macOS/]https://packages.millistream.com/macOS/[/blue link]\n\n"
81
+ f"Download and run the latest installer and follow the on-screen instructions. After that, you're done!\n\n"
82
+ f"For more information, visit: [blue link=https://github.com/mint273/millistream-mdf]https://github.com/mint273/millistream-mdf[/blue link]"
83
+ ))
84
+
85
+
86
+ def install_windows() -> None:
87
+ """Install libmdf for Windows"""
88
+ console.print(Panel(
89
+ f"Installation notice for [bold]Windows[/bold]:\n\n"
90
+ f"For [bold]Windows[/bold], it's recommended to install the necessary dependency 'libmdf' using the [bold].exe[/bold] installer from [blue link=https://packages.millistream.com/Windows/]https://packages.millistream.com/Windows/[/blue link]\n\n"
91
+ f"Download and run the latest installer and follow the on-screen instructions. After that, you're done!\n\n"
92
+ f"For more information, visit: [blue link=https://github.com/mint273/millistream-mdf]https://github.com/mint273/millistream-mdf[/blue link]"
93
+ ))
94
+
95
+
96
+
97
+
98
+
99
+ def install_deps() -> None:
100
+ """Install dependencies for the current platform"""
101
+ if sys.platform == 'linux':
102
+ install_linux()
103
+ elif sys.platform == 'darwin':
104
+ install_macos()
105
+ elif sys.platform == 'win32':
106
+ install_windows()
107
+
108
+ def print_version() -> None:
109
+ """Print the version of the package"""
110
+ print(f'Version: {__version__}')
111
+
112
+
113
+
114
+ def main() -> None:
115
+ parser = argparse.ArgumentParser(description='Millistream MDF')
116
+ parser.add_argument('--install-deps', action='store_true', help='Install dependencies')
117
+ parser.add_argument('--version', action='store_true', help='Show version')
118
+ args = parser.parse_args()
119
+
120
+ if args.install_deps:
121
+ install_deps()
122
+ elif args.version:
123
+ print_version()
124
+
125
+
126
+
127
+
128
+
129
+
130
+ if __name__ == "__main__":
131
+ main()