コード例 #1
0
def open(url):
    """Open specific URL on teleserver
    """
    logger.info('Opening URL...')
    logger.debug(f'args: url: {url}')
    response = make_request('webbrowser/open', {'url': url})
    logger.info(f"Server response: {response['message']}")
コード例 #2
0
def set_volume(level):
    """Set volume to specific level
    """
    logger.info('Setting volume...')
    logger.debug('args: level: {level}')
    response = make_request('system/set_volume', {'lvl': level})
    logger.info(f"Server response: {response['message']}")
コード例 #3
0
def call_word(word):
    """Call specific word or key string
    """
    logger.info('Calling word')
    logger.debug(f'args: word: {word}')
    response = make_request('keyboard/call_word', {'word': word})
    logger.info(f"Server response: {response['message']}")
コード例 #4
0
def call_key(key):
    """Call specific key in xdotool format
    """
    logger.info('Calling key...')
    logger.debug(f'args: key: {key}')
    response = make_request('keyboard/call_key', {'key': key})
    logger.info(f"Server response: {response['message']}")
コード例 #5
0
def grab_screen(output):
    """Take a screenshot and save it to local files
    """
    logger.info(f'Grabbing screen and saving to {output}')
    logger.debug(f'args: output: {output}')
    response = make_request('system/grab_screen')
    logger.info(f"Server response: {response['message']}")
    imgdata = base64.b64decode(response['screen'])
    with open(output, 'wb') as f:
        f.write(imgdata)
    logger.info(f'Saved image to {output}')
コード例 #6
0
 def test_make_request(self, mock_post):
     test_credentials = {
         'token_name': 'testtoken',
         'token': 'secret',
         'server': '127.0.0.1'
     }
     os.makedirs('~/.teleserver')
     with open('~/.teleserver/credentials.json', 'w') as f:
         json.dump(test_credentials, f)
     url_args = {'var1': 'val1', 'var2': 'val2'}
     route = 'test/route'
     post_args = {
         'postvar1': 'postval1',
         'postvar2': 'postval2',
         'postvar3': 'postval3'
     }
     response = make_request(route=route,
                             url_args=url_args,
                             post_args=post_args)
     self.assertEqual(response['rc'], 0)
コード例 #7
0
def mute():
    """Mute the volume
    """
    logger.info('Muting...')
    response = make_request('system/mute')
    logger.info(f"Server response: {response['message']}")
コード例 #8
0
def screenshot():
    """Take a screenshot of teleserver
    """
    logger.info('Making screenshot...')
    response = make_request('system/screenshot')
    logger.info(f"Server response: {response['message']}")
コード例 #9
0
def reboot():
    """Reboot teleserver machine
    """
    logger.info('Rebooting...')
    response = make_request('system/reboot')
    logger.info(f"Server response: {response['message']}")
コード例 #10
0
def poweroff():
    """Power off teleserver machine
    """
    logger.info('Powering off...')
    response = make_request('system/poweroff')
    logger.info(f"Server response: {response['message']}")
コード例 #11
0
def close():
    """Close web browser on teleserver
    """
    logger.info('Closing webbrowser...')
    response = make_request('webbrowser/close')
    logger.info(f"Server response: {response['message']}")
コード例 #12
0
def openmeet():
    """Open well-known Google Meet link
    """
    logger.info('Opening meet...')
    response = make_request('webbrowser/openmeet')
    logger.info(f"Server response: {response['message']}")