forked from Ratfink/ds1054z-screen-capture
-
Notifications
You must be signed in to change notification settings - Fork 2
/
dm3058-capture
executable file
·44 lines (35 loc) · 1.37 KB
/
dm3058-capture
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3
from rigol import *
from common import *
import time
import sys
import os
import argparse
script_name = os.path.basename(sys.argv[0])
filepath = os.getcwd()
parser = argparse.ArgumentParser(description='Rigol DM3058 Digital Multimeter data capture.')
parser.add_argument("ip_address", nargs='?', default=None,
help=("IP address of a network or a host. Can be "
"IPv4 or IPv6 address"))
parser.add_argument("-I", "--imgur", action='store_true',
help="Upload to Imgur")
parser.add_argument("-P", "--preview", action='store_true',
help="Preview Image")
args = parser.parse_args()
if args.ip_address is not None:
INSTRUMENT_IP = args.ip_address
else:
INSTRUMENT_IP = find_arp(RIGOL_OUI)
if INSTRUMENT_IP is None:
sys.exit("Error: Hardware address not found in ARP table, IP will have to be specified manually.")
print("Capturing screenshot..")
timestamp = time.strftime("%Y-%m-%d_%H:%M:%S", time.localtime())
filename = "DM3058_%s.bmp" % (timestamp)
file_length = dm3058_screenshot(INSTRUMENT_IP, "%s/%s" % (filepath, filename))
if not file_length:
sys.exit('Capture failed')
print("Saved screenshot to %s (%.1fKB)" % (filename, file_length/1024.0))
if args.preview:
image_preview(filename)
if args.imgur:
imgur_post(filename, "DM3058 Screen Capture")