Пример #1
0
def test_echo_vs_copy():
    # no copy nor echo
    expected = "phones.myphone"
    xerox.copy("")
    result = invoke_cli("--no-copy", "--no-echo", "myphone")
    assert not result.exception and result.exit_code == 0
    assert result.output.strip() == expected.strip()
    assert xerox.paste() == ""

    # only echo
    expected = "phones.myphone | 0000"
    xerox.copy("")
    result = invoke_cli("--no-copy", "--echo", "myphone")
    assert not result.exception and result.exit_code == 0
    assert result.output.strip() == expected.strip()
    assert xerox.paste() == ""

    # only echo
    expected = "phones.myphone | *** PASSWORD COPIED TO CLIPBOARD ***"
    xerox.copy("")
    result = invoke_cli("--copy", "--no-echo", "myphone")
    assert not result.exception and result.exit_code == 0
    assert result.output.strip() == expected.strip()
    assert xerox.paste() == "0000"

    # both copy and echo
    expected = "phones.myphone | 0000 | *** PASSWORD COPIED TO CLIPBOARD ***"
    xerox.copy("")
    result = invoke_cli("--copy", "--echo", "myphone")
    assert not result.exception and result.exit_code == 0
    assert result.output.strip() == expected.strip()
    assert xerox.paste() == "0000"
Пример #2
0
def main2():
    #from dbgp.client import brk
    #brk(host="191.168.45.215", port=50803)
    #msg = "good"
    #if len(sys.argv) >= 2:
    #   msg = sys.argv[1]
    global flag
    def handler(signum, frame):
        print 'Signal handler called with signal', signum
        while True:
            in_put = raw_input("please input 'c' continue or 'e' exit:")
            if in_put == 'e':
                #exit()
                global flag
                flag = False
                break
            elif in_put == 'c':
                break
    signal.signal(signal.SIGINT, handler)
    youdao = Youdao()
    #youdao.get_translation(msg)
    print "start youdao_copy"
    word = xerox.paste()
    while(flag):
        word_new = xerox.paste()
        if word_new != word:
            print word_new
            youdao.get_translation(word_new)
            word = word_new
        else:
            time.sleep(0.1)
            
    print "exit youdao_copy"
Пример #3
0
 def test_copy_xsel(self):
     if not sys.platform.startswith('linux'):
         return
     xerox.copy(self.text, xsel=True)
     # Check that we can copy from the clipboard and the X selection
     self.assertEqual(xerox.paste(), self.text)
     self.assertEqual(xerox.paste(xsel=True), self.text)
Пример #4
0
def listen():
    k_adi = getpass.getuser()
    if os.name == "nt":
        path = "C:\\Users\\%s\\Desktop\\" % (str(k_adi))
    else:
        if k_adi != "root":
            try:
                os.chdir("/home/" + k_adi + "/Masaüstü/")
                path = "/home/" + k_adi + "/Masaüstü/"
            except OSError:
                os.chdir("/home/" + k_adi + "/Desktop/")
                path = "/home/" + k_adi + "/Desktop/"

        else:
            try:
                os.chdir("/root/Masaüstü/")
                path = "/root/Masaüstü/"
            except OSError:
                os.chdir("/root/Desktop/")
                path = "/root/Desktop/"

    file = open(path + "musics.txt", "a")
    print "[+] Dosya, '%s' dizinine açıldı.\n" % (path + "musics.txt")
    while True:
        try:
            if "youtube" in xerox.paste() and "watch" in xerox.paste():
                url = xerox.paste()
                file.write(url + "\n")
                xerox.copy("Tamamdir")
                print "[>] Dosyaya yazılan: %s" % (url)
            else:
                pass
        except KeyboardInterrupt:
            print "\n[!] CTRL+C algılandı, çıkılıyor..."
            sys.exit(0)
Пример #5
0
def main2():
    #from dbgp.client import brk
    #brk(host="191.168.45.215", port=50803)
    #msg = "good"
    #if len(sys.argv) >= 2:
    #   msg = sys.argv[1]
    global flag

    def handler(signum, frame):
        print 'Signal handler called with signal', signum
        while True:
            in_put = raw_input("please input 'c' continue or 'e' exit:")
            if in_put == 'e':
                #exit()
                global flag
                flag = False
                break
            elif in_put == 'c':
                break

    signal.signal(signal.SIGINT, handler)
    youdao = Youdao()
    #youdao.get_translation(msg)
    print "start youdao_copy"
    word = xerox.paste()
    while (flag):
        word_new = xerox.paste()
        if word_new != word:
            print word_new
            youdao.get_translation(word_new)
            word = word_new
        else:
            time.sleep(0.1)

    print "exit youdao_copy"
Пример #6
0
def test_cli_clipboard(checklist, tmpdir, test_format_configs):
    runner = CliRunner()
    for frmt, fpath, known_good in test_format_configs:
        result = runner.invoke(
            main, ['--checklist', checklist, '--clipboard', '--format', frmt])
        assert result.exit_code == 0
        if frmt != 'html':  # full doc for html not returned with format
            assert xerox.paste() == str(known_good)

    result = runner.invoke(main, ['--checklist', checklist, '-c'])
    assert result.exit_code == 0
    assert xerox.paste() == assets.known_good_markdown
Пример #7
0
    def OnKeyPress(self, event):
        """
        function called when any key is pressed
        """
        global prev_Key, key_binding

        if event.Key == key_binding[1] and prev_Key == key_binding[0]:
            if utils.active == 1:
                utils.active = 0
            elif utils.active == 0:
                utils.active = 1
            prev_Key = None

        elif event.Key == 'c' and prev_Key == 'Control_L':
            self.text = xerox.paste(xsel=True)
            utils.clips.append(self.text)
            # pickle clips data
            with open(os.path.join(os.path.dirname(__file__), 'clips_data'),
                      "wb") as f:
                pickle.dump(utils.clips, f, protocol=2)

            print("You just copied: {}".format(self.text))

        elif event.Key == 'z' and prev_Key == 'Control_L':
            print("can")
            self.new_hook.cancel()

        else:
            prev_Key = event.Key

        return True
Пример #8
0
def get_clipboard():
    """
    Get content of OS clipboard.
    """
    if 'xerox' in sys.modules.keys():
        print("Returning clipboard content using xerox...")
        return xerox.paste()
    elif 'pyperclip' in sys.modules.keys():
        print("Returning clipboard content using pyperclip...")
        return pyperclip.paste()
    elif 'gtk' in sys.modules.keys():
        print("Returning clipboard content using gtk...")
        clipboard = gtk.clipboard_get()
        return clipboard.wait_for_text()
    elif 'win32clipboard' in sys.modules.keys():
        wcb = win32clipboard
        wcb.OpenClipboard()
        try:
            data = wcb.GetClipboardData(wcb.CF_TEXT)
        except TypeError as err:
            print(err)
            print("No text in clipboard.")
        wcb.CloseClipboard() # User cannot use clipboard until it is closed.
        return data
    else:
        #print("sys.modules.keys() is: ", sys.modules.keys())
        print("Neither of win32clipboard, gtk, pyperclip, or xerox available.")
        print("- Falling back to Tk...")
        tkroot = Tk()
        tkroot.withdraw()
        result = tkroot.selection_get(selection="CLIPBOARD")
        tkroot.destroy()
        print("Returning clipboard content using Tkinter...")
        return result
Пример #9
0
def autoput_contact_profile_info(s):
    data = xerox.paste()
    i = 0
    for line in data.split('\n'):
        print(s)
        if len(line):
            a = 1
            if i == 0:
                l = line.split()
                s['name'] = l[0] + ' ' + l[1]
            elif i == 1:
                if len(line.split()) > 2:
                    s['bio'] = line
                else:
                    a = 0
            elif i == 2:
                s['job'] = line.strip()
            elif i == 3:
                s['loc'] = line.strip()
            elif i == 4:
                s['email'] = line.strip()
            elif i == 5:
                s['page'] = line.strip()
            i += a
    serialize_session(s)
Пример #10
0
def main():
    parser = optparse.OptionParser()
    using_help = '''
    the service that you want to use. For example: gist for Github's Gist,
    pastebin for PasteBin.com
    '''
    parser.add_option('-u', '--using', dest='using',
                      help=using_help)

    (options, args) = parser.parse_args()

    using = options.using
    if not using:
        using = 'pastebin'

    obj = SharePastesFactory.create(using)
    try:
        url = obj.api_call(xerox.paste())
        xerox.copy(url)
    except xerox.base.XclipNotFound:
        print 'xclip not found. Install xclip for SharePastes to work.'
        sys.exit(1)

    try:
        from pync import Notifier
        Notifier.notify('URL added to your clipboard %s.' % url,
                        title='SharePastes')
    except:
        pass
Пример #11
0
def get_input_from_argparse(callback, parsed_args):
    print_debug(parsed_args)
    parsed_args = parsed_args.copy()
    source = parsed_args.get('source')
    print_debug("get_input args", parsed_args)

    if parsed_args.get("confirm"):
        del parsed_args['confirm']
        def confirmed_cb(b):
            if b:
                get_input_from_argparse(callback, parsed_args)
        if is_mainthread():
            send_getbool_to_callback(confirmed_cb)
        else:
            hexchat.hook_timer(20, send_getbool_to_callback, confirmed_cb)
        return

    if source == "inputbox":
        if not parsed_args['guard_inputbox_cmd']:
            callback(ibx.get())
        else:
            callback(parsed_args['guard_inputbox_cmd'][1])

    elif source == "clipboard" and HAVE_XEROX:
        callback(xerox.paste())

    elif source == "window":
        # Ask main thread to getstr and then give it to our callback.
        if is_mainthread():
            send_getstr_to_callback(callback)
        else:
            hexchat.hook_timer(20, send_getstr_to_callback, callback)

    else:
        raise FloodcontrolError("Could not get input. Requested source: {}".format(source))
Пример #12
0
def get_clipboard():
    """
    Get content of OS clipboard.
    """
    if 'xerox' in sys.modules.keys():
        print "Returning clipboard content using xerox..."
        return xerox.paste()
    elif 'pyperclip' in sys.modules.keys():
        print "Returning clipboard content using pyperclip..."
        return pyperclip.paste()
    elif 'gtk' in sys.modules.keys():
        print "Returning clipboard content using gtk..."
        clipboard = gtk.clipboard_get()
        return clipboard.wait_for_text()
    elif 'win32clipboard' in sys.modules.keys():
        wcb = win32clipboard
        wcb.OpenClipboard()
        try:
            data = wcb.GetClipboardData(wcb.CF_TEXT)
        except TypeError as e:
            print e
            print "No text in clipboard."
        wcb.CloseClipboard() # User cannot use clipboard until it is closed.
        return data
    else:
        print "locals.keys() is: ", sys.modules.keys().keys()
        print "falling back to Tk..."
        r = Tk()
        r.withdraw()
        result = r.selection_get(selection="CLIPBOARD")
        r.destroy()
        print "Returning clipboard content using Tkinter..."
        return result
Пример #13
0
def get_clipboard():
    """
    Get content of OS clipboard.
    """
    if 'xerox' in list(sys.modules.keys()):
        print("Returning clipboard content using xerox...")
        return xerox.paste()
    elif 'pyperclip' in list(sys.modules.keys()):
        print("Returning clipboard content using pyperclip...")
        return pyperclip.paste()
    elif 'gtk' in list(sys.modules.keys()):
        print("Returning clipboard content using gtk...")
        clipboard = gtk.clipboard_get()
        return clipboard.wait_for_text()
    elif 'win32clipboard' in list(sys.modules.keys()):
        wcb = win32clipboard
        wcb.OpenClipboard()
        try:
            data = wcb.GetClipboardData(wcb.CF_TEXT)
        except TypeError as e:
            print(e)
            print("No text in clipboard.")
            data = None
        wcb.CloseClipboard()  # User cannot use clipboard until it is closed.
        return data
    else:
        print("locals.keys() is: ", list(sys.modules.keys()).keys())
        print("falling back to Tk...")
        r = Tk()
        r.withdraw()
        result = r.selection_get(selection="CLIPBOARD")
        r.destroy()
        print("Returning clipboard content using Tkinter...")
        return result
Пример #14
0
def paste():
    if droid:
        x = droid.getClipboard()
        result = x.result
    else:
        result = xerox.paste()
    return result
Пример #15
0
def main():
    curl_input = xerox.paste()
    print("Input: -----")
    print(curl_input)
    print("-----\n\n")
    context = uncurl.parse_context(curl_input)
    request_data = json.loads(context.data)
    url = urlparse(context.url)
    query_params = get_query_dict(url.query)
    cookie_string = ";".join(f"{key}={value}"
                             for key, value in context.cookies.items())
    postman_collection = {
        "info": {
            "name":
            request_data["operationName"],
            "schema":
            "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
        },
        "item": [{
            "name": request_data["operationName"],
            "request": {
                "method": "POST",
                "header": [],
                "body": {
                    "mode": "graphql",
                    "graphql": {
                        "query": request_data["query"],
                        "variables": json.dumps(request_data["variables"]),
                    },
                },
                "url": {
                    "raw":
                    context.url,
                    "protocol":
                    url.scheme,
                    "host": [url.hostname],
                    "port":
                    url.port,
                    "path":
                    url.path.split("/"),
                    "query": [{
                        "key": key,
                        "value": value
                    } for key, value in query_params.items()],
                },
            },
            "response": [],
        }],
        "protocolProfileBehavior": {},
    }
    result = json.dumps(postman_collection)
    print("----- Postman Collection ----")
    print(result)
    print("---- Headers -----")
    for key, value in context.headers.items():
        print(f"{key}:{value}")
    print(f"Cookie:{cookie_string}")
    print("-----")
    xerox.copy(result)
Пример #16
0
 def copyFromClipBoard(self):
     #take temp copy of clipboard to prevent insert same value all the time
     #and also for prevent to insert trash like copy from last run
     tempCopiedClipboard = xerox.paste()
     copiedClipboard = None
     while True:
         try:
             copiedClipboard = xerox.paste()
             if(copiedClipboard != tempCopiedClipboard and copiedClipboard is not None):
                 tempCopiedClipboard = copiedClipboard
                 # self.insertToDict(pasteboardString)
                 self.refreshAndUpdateDataFromRedisDB(copiedClipboard)
                 self.updatreDBValues()
                 self.updateElasticIndexes(copiedClipboard)
                 self.updateMongoDBValues(copiedClipboard)
         except Exception as error:
             self.logger.error(error)
Пример #17
0
 def paste_formatted_text(self, font_type):
     """
     Paste the currently selected text in the clipboard with the input font type
     :param font_type: name of font
     """
     font = self.fonts_dict.get(font_type, 'Serif-Normal')
     text = xerox.paste(xsel=True)
     ftext = ''.join(list(map(lambda ch: font.get(ch, ch), text)))
     xerox.copy(ftext)
Пример #18
0
 def run(self):
     recent_value = ""
     while not self._stopping:
         tmp_value = xerox.paste()
         if tmp_value != recent_value:
             recent_value = tmp_value
             if self._predicate(recent_value):
                 self._callback(recent_value)
         time.sleep(self._pause)
Пример #19
0
    def test_copy_and_paste(self):
        # copy
        self.assertIsInstance(self.text, str)
        xerox.copy(self.text)

        # paste
        got = xerox.paste()
        self.assertIsInstance(got, str)
        self.assertEqual(got, self.text)
Пример #20
0
def getCopyText():
    '''
    获得剪切板数据
    '''
    try:
        copy_text = xerox.paste()
    except TypeError:
        copy_text = 'Please copy text!!!'
    return copy_text
Пример #21
0
    def on_key_press( self, symbol, modifiers ):
        # whether we handle the text here 
        self.texthandled = 0
        
        # kill the alert if you push anything
        self.alerttime = 0
        # some global key strokes
        if symbol == key.F11:
            if self.fullscreenwait == 0:
                self.set_fullscreen( not self.fullscreen )
                self.fullscreenwait = 1 # wait a second before allowing switching back
                self.activate()
                self.set_focus(None)
            self.texthandled = 1
        elif (symbol == key.Q or symbol == key.W) and modifiers & key.MOD_CTRL:
            pyglet.app.exit()
        # check for command mode...
        elif self.commandmode:
            if symbol == key.RETURN:
                # if we pressed enter after entering a command...
                self.setcommand( False )
                self.texthandled = 1
        # check for inputting things in some other focus box...
        elif self.focus:
            # if we are focused on some input device, don't let
            # any other commands be available except to possibly escape from it,
            # also basic copy and paste.
            if symbol == key.ESCAPE:
                self.set_focus( None )
                self.texthandled = 1
            elif symbol == key.C and modifiers & key.MOD_CTRL:
                xerox.copy(  self.focus.getselectedtext()  )
                self.texthandled = 1
            elif symbol == key.V and modifiers & key.MOD_CTRL:
                self.focus.dealwithtext( xerox.paste() )
                self.texthandled = 1
        # otherwise look at what it could mean for the global guy
        else:
            if ( symbol == key.Q or symbol == key.ESCAPE ):
                self.texthandled = 1
                self.alert( "ctrl+Q or ctrl+W to quit" )
            elif symbol == key.SLASH:
                self.texthandled = 1
                self.setcommand() # get command mode ready

            elif symbol == key.W:
                self.alert(self.lastalert,10)

            elif symbol == key.S:
                self.savefile()

            elif symbol == key.E:
                self.loadfile( "scratch" )

        print "key press ", symbol, " are we handled? ", self.texthandled
        return pyglet.event.EVENT_HANDLED
Пример #22
0
    def on_key_press(self, symbol, modifiers):
        # whether we handle the text here
        self.texthandled = 0

        # kill the alert if you push anything
        self.alerttime = 0
        # some global key strokes
        if symbol == key.F11:
            if self.fullscreenwait == 0:
                self.set_fullscreen(not self.fullscreen)
                self.fullscreenwait = 1  # wait a second before allowing switching back
                self.activate()
                self.set_focus(None)
            self.texthandled = 1
        elif (symbol == key.Q or symbol == key.W) and modifiers & key.MOD_CTRL:
            pyglet.app.exit()
        # check for command mode...
        elif self.commandmode:
            if symbol == key.RETURN:
                # if we pressed enter after entering a command...
                self.setcommand(False)
                self.texthandled = 1
        # check for inputting things in some other focus box...
        elif self.focus:
            # if we are focused on some input device, don't let
            # any other commands be available except to possibly escape from it,
            # also basic copy and paste.
            if symbol == key.ESCAPE:
                self.set_focus(None)
                self.texthandled = 1
            elif symbol == key.C and modifiers & key.MOD_CTRL:
                xerox.copy(self.focus.getselectedtext())
                self.texthandled = 1
            elif symbol == key.V and modifiers & key.MOD_CTRL:
                self.focus.dealwithtext(xerox.paste())
                self.texthandled = 1
        # otherwise look at what it could mean for the global guy
        else:
            if (symbol == key.Q or symbol == key.ESCAPE):
                self.texthandled = 1
                self.alert("ctrl+Q or ctrl+W to quit")
            elif symbol == key.SLASH:
                self.texthandled = 1
                self.setcommand()  # get command mode ready

            elif symbol == key.W:
                self.alert(self.lastalert, 10)

            elif symbol == key.S:
                self.savefile()

            elif symbol == key.E:
                self.loadfile("scratch")

        print "key press ", symbol, " are we handled? ", self.texthandled
        return pyglet.event.EVENT_HANDLED
Пример #23
0
 def run(self):
     """ Run clipboard pooling and report to reporter function
     if content has been changed. """
     recent_value = ''
     while not self._stopping:
         new_value = xerox.paste()
         if new_value != recent_value:
             recent_value = new_value
             self._reporter(recent_value)
         sleep(self._interval)
Пример #24
0
def get_code(args):
  code = ''

  if args.file is not None and type(args.file) is str:
    f = open(args.file)
    code = f.read()
  else:
    code = xerox.paste()

  return code
Пример #25
0
    def transpose_csv():
        """ Transposes csv data

        Takes copied csv data from the copy buffer, rotates it, and
        replaces it
        """
        data = xerox.paste().split("\n")
        transposed = zip(*[x.strip().split(",") for x in data])
        new_text = "\n".join([",".join(y) for y in transposed])
        xerox.copy(new_text)
Пример #26
0
def getCopyText():
    '''
    获得剪切板数据
    '''
    try:
        copy_text = xerox.paste(xsel=True)
    except TypeError:
        copy_text = 'Please copy text!!!'
    # except pywintypes.error:
    #     copy_text = 'Please copy text!!!'
    return copy_text
Пример #27
0
def get_clip_input():
    split_input = []
    clip_input = xerox.paste(xsel=True)

    split_input = clip_input.splitlines()

    if len(split_input) == 4:
        clip_input = split_input
        return clip_input
    else:
        raise BadClipboardContentsError("Bad clipboard contents, try copy again")
Пример #28
0
    def on_press(self, key):
        """
        function called when any key is pressed
        """
        global prev_Key, key_binding
        if (key == keyboard.Key.space and
            (prev_Key == keyboard.Key.ctrl or
                prev_Key == keyboard.Key.cmd)):
            if utils.active == 1:
                utils.active = 0
            elif utils.active == 0:
                utils.active = 1
            prev_Key = None

        elif (((pprint.pformat(key) == "'c'" or
                pprint.pformat(key) == "u'c'") and
                prev_Key == keyboard.Key.ctrl) or
                pprint.pformat(key) == "'\\x03'" or
                pprint.pformat(key) == "'\\xe7'" or
                pprint.pformat(key) == "u'\\xe7'"):
            try:
                if curros == "win":
                    time.sleep(.2)
                    self.text = utils.root.clipboard_get()
                elif curros == "linux":
                    self.text = xerox.paste()
                else:
                    time.sleep(.2)
                    self.text = utils.root.clipboard_get().encode('utf-8')

            except:
                self.text = ""

            utils.clips.append(self.text)
            # pickle clips data
            with open(os.path.join(os.path.dirname(__file__),
                      'clips_data'), "wb") as f:
                pickle.dump(utils.clips, f, protocol=2)

            print("You just copied: {}".format(self.text))

        elif (((pprint.pformat(key) == "'z'" or
                pprint.pformat(key) == "u'z'") and
                prev_Key == keyboard.Key.ctrl) or
                pprint.pformat(key) == "'\\x1a'" or
                pprint.pformat(key) == "'\\u03a9'" or
                pprint.pformat(key) == "u'\\u03a9'"):
            utils.root.destroy()
            self.stop()

        else:
            prev_Key = key

        return True
Пример #29
0
def main():
    if sys.stdin.isatty():
        if len(sys.argv) > 1:
            # If an argument is passed
            result = parse(sys.argv[1])
        else:
            # Otherwise pull from clipboard
            result = parse(xerox.paste())
    else:
        result = parse(sys.stdin.read())
    print(result)
Пример #30
0
 def run(self):
     youdao = Youdao()
     #youdao.get_translation(msg)
     print "start youdao_copy"
     xerox.copy("你好")
     word = None
     word_new = None
     err_old = None
     try:
         word = xerox.paste()
     except BaseException, err:
         print err
Пример #31
0
 def run(self):
     youdao = Youdao()
     #youdao.get_translation(msg)
     print "start youdao_copy"
     xerox.copy("你好")
     word = None
     word_new =None
     err_old = None
     try :
         word = xerox.paste()
     except BaseException,err:
         print err
Пример #32
0
    def find_password(self):
        with open('brute_param.json') as json_file:
            param = json.load(json_file)

        current = browser.get('safari')
        current.open(self.web_address)

        time.sleep(1)
        flag = 0

        for i in range(0, 10):
            if flag == 1:
                break
            for j in range(0, 10):
                if flag == 1:
                    break
                for k in range(0, 10):
                    if flag == 1:
                        break

                    password = str(i) + str(j) + str(k)

                    auto.press('tab')
                    keyboard.write(param['username'])

                    auto.press('tab')
                    keyboard.write(password)

                    auto.press('tab')
                    auto.press('enter')

                    auto.press('tab')
                    auto.hotkey(
                        'command', 'q'
                    )  #===> NOTE: on "qwerty" keyboards, replace "q" by "a"
                    auto.hotkey('command', 'c')

                    webpage_reply = xerox.paste()

                    print(password)
                    print(webpage_reply)
                    print()

                    if "Incorrect" in webpage_reply:
                        for n in range(
                                0, 8
                        ):  #===> NOTE: the number of necessary 'tab' can change
                            auto.press('tab')
                        auto.press('enter')
                        xerox.copy("stop")
                    else:
                        flag = 1
Пример #33
0
def main():
    curl_input = xerox.paste()
    context = uncurl.parse_context(curl_input)
    try:
        request_data = json.loads(context.data)
    except JSONDecodeError:
        request_data = context.data
    print(request_data.replace("\\n", "\n"))
    print(request_data["operationName"])
    print("-----\n\n")
    print(request_data["query"])
    print("-----\n\n")
    print(json.dumps(request_data["variables"], indent=2))
Пример #34
0
def OnKeyPress(event):
    global prev_Key, active
    if event.Key == 'space' and prev_Key == 'Control_L' and active == 0:
        active = 1
        clipboard(clips)
        active = 0
        prev_Key = None
    elif event.Key == 'c' and prev_Key == 'Control_L':
        text = xerox.paste(xsel=True)
        clips.append(text)
        print("You just copied: {}".format(text))
    else:
        prev_Key = event.Key
Пример #35
0
    def OnInit(self):
        self.frame = MyFrame(None, wx.ID_ANY, "")
        # use the clipboard content for the URL
        self.frame.url = xerox.paste()
        # https://stackoverflow.com/questions/32542703/how-to-find-a-folder-path-in-mac-os-x-using-python
        self.frame.save_path = os.path.expanduser("~/Desktop")

        # https://wiki.wxpython.org/WxLibPubSub
        pub.subscribe(self.do_url2pdf, 'confirmed_to_go')

        self.SetTopWindow(self.frame)
        self.frame.Show()
        return True
Пример #36
0
def simpleMain():
    try:
        recent_value = ""
        while True:
            tmp_value = xerox.paste()
            if useIfStarts == tmp_value[
                    0:len(useIfStarts)] and tmp_value != recent_value and len(
                        tmp_value) > len(useIfStarts):
                recent_value = tmp_value
                PasteKeystrokes(tmp_value[len(useIfStarts):])
            time.sleep(sleepTime)
    except KeyboardInterrupt:
        bye()
Пример #37
0
    def start(self):
        temp_value = ''

        while True:
            recent_value = paste()
            if recent_value != temp_value:
                result = self.translate.send_request(recent_value)
                if result['status'] == True:
                    self.notify.send(recent_value, result['response'])
                else:
                    print('Error: ' + str(result['response']))

            temp_value = recent_value
            sleep(2)
Пример #38
0
def get_clipboard_data():
    try:
        import pyperclip
        return pyperclip.paste()
    except ImportError:
        print("get_clipboard_data(): pyperclip not available.",
              file=sys.stderr)
    try:
        import xerox
        return xerox.paste()
    except ImportError:
        print("get_clipboard_data(): xerox not available.", file=sys.stderr)
    raise RuntimeError(
        "Could not find any way to retrieve clipboard data. Please install xerox or pyperclip packages."
    )
Пример #39
0
def main():
    '''Main entry point for the tbpaste CLI.'''
    args = docopt(__doc__, version=__version__)
    command = args["<command>"]
    text = unicode(xerox.paste())
    blob = tb(text)
    tokenize = 't' in args['--sentences'].lower()
    if command == 'lang' or args['--to'] or args['--from']:
        return lang(blob, from_lang=args['--from'], to=args['--to'])
    elif command == 'chunks':
        return chunks(blob, tokenize)
    elif command == 'tag':
        return tag(blob)
    else:
        return sentiment(blob, tokenize)
    sys.exit(0)
Пример #40
0
Файл: set.py Проект: snark/pink
def action(args):
    # TODO Handle STDIN on set
    # TODO Handle annotations
    keyword = args.keyword
    namespace = args.namespace
    text = args.text
    if not text:
        text = xerox.paste()

    conn = util.connect_database()
    if not conn:
        exit('Unable to access %s; exiting' % util.DB_LOCATION)

    util.set_clipping(
        conn,
        key=keyword,
        namespace=namespace,
        value=text
    )
    return "Set value for %s/%s" % (namespace, keyword)
Пример #41
0
def get_clipboard():
    """Get content of OS clipboard.

    This function tries a range of modules and methods to find a suitable way to get the clipboard content.

    Example:
        >>> get_clipboard()
        "hello there"

    """
    if 'xerox' in sys.modules.keys():
        print("Returning clipboard content using xerox...")
        return xerox.paste()
    elif 'pyperclip' in sys.modules.keys():
        print("Returning clipboard content using pyperclip...")
        return pyperclip.paste()
    elif 'gtk' in sys.modules.keys():
        print("Returning clipboard content using gtk...")
        clipboard = gtk.clipboard_get()
        return clipboard.wait_for_text()
    elif 'win32clipboard' in sys.modules.keys():
        wcb = win32clipboard
        wcb.OpenClipboard()
        try:
            data = wcb.GetClipboardData(wcb.CF_TEXT)
        except TypeError as err:
            print(err)
            print("No text in clipboard.")
        else:
            wcb.CloseClipboard()  # User cannot use clipboard until it is closed.
            return data
    else:
        print("locals.keys() is: ", sys.modules.keys().keys())
        print("falling back to Tk...")
        tkroot = Tk()
        tkroot.withdraw()
        result = tkroot.selection_get(selection="CLIPBOARD")
        tkroot.destroy()
        print("Returning clipboard content using Tkinter...")
        return result
Пример #42
0
 def clipboard_get(self):
     return xerox.paste().split('\n')
Пример #43
0
  config = ConfigParser.ConfigParser()
  config.read([resource_filename(Requirement.parse("bitcpy"),"bitcpy/bitcpy.conf"), 
               os.path.expanduser("~/.bitcpyrc")])

  try:
    BITLY_API_USERNAME     = config.get("bitcpy", "BITLY_API_USERNAME")
    BITLY_API_PASSWORD     = config.get("bitcpy", "BITLY_API_PASSWORD")
    TIMEOUT                = config.getfloat("bitcpy", "TIMEOUT")
  except Exception, e:
    import sys
    print e
    sys.exit(-1)
  
  try:
    BITLY_PREFERRED_DOMAIN = config.get("bitcpy", "BITLY_PREFERRED_DOMAIN")
  except ConfigParser.NoOptionError:
    BITLY_PREFERRED_DOMAIN = "bit.ly"

  b = BitCpy(BITLY_API_USERNAME, BITLY_API_PASSWORD, BITLY_PREFERRED_DOMAIN)
  laststr = ""
  while True:
    newstr = xerox.paste()
    if laststr != newstr and newstr is not "":
      bitified = b.bitify_string(newstr)
      xerox.copy(bitified)
      laststr = bitified
    time.sleep(TIMEOUT)

if __name__ == "__main__":
  main()
Пример #44
0
	def add_item(self, event):
		review_name = xerox.paste()
		self.rl.add_item(review_name)
		self.alert_message.show_message("Added!")
Пример #45
0
def PasteURL():
    URL=xerox.paste()
    DownloadURLEntry.delete("0","end")
    DownloadURLEntry.insert("end",URL)
Пример #46
0
 def test_paste(self):
     xerox.copy(self.text)
     self.assertEqual(xerox.paste(), self.text)
Пример #47
0
def main(argv):
    s=xerox.paste()   
    s = s.splitlines()
    s = ''.join(s)
    xerox.copy(s)
    return s    
Пример #48
0
 def test_empty(self):
     xerox.copy('')
     self.assertEqual(xerox.paste(), '')
Пример #49
0
 def test_unicode(self):
     unicode_text = u'Ξεσκεπάζω τὴν ψυχοφθόρα βδελυγμία'
     xerox.copy(unicode_text)
     self.assertEqual(xerox.paste(), unicode_text)