def main(): from pprint import pprint import pyperclip url = 'http://up.imgapi.com/' # www.tietuku.com申请一个就可以了,尽量不要用这个吧,我也不知道是不是有频率额度限制之类的 token = 'd13b47d1235c806bac31f8624fade749c48879dd:1i2LBNV7CU9QCGuFDev6ea9YXNU=:eyJkZWFkbGluZSI6MTQ5NjMxMTgxMSwiYWN0aW9uIjoiZ2V0IiwidWlkIjoiNTk2MDI5IiwiYWlkIjoiMTMxMjQxNyIsImZyb20iOiJmaWxlIn0=' data = { 'Token': token, } with open(sys.argv[1], 'rb') as fin: while True: try: r = requests.post(url, data=data, files={'file': fin}, timeout=3) break except: pass r = json.loads(r.text) pprint(r) print('-' * 30) pyperclip.set_clipboard('xclip') pyperclip.copy(r['linkurl']) print('图片地址已经复制到系统粘贴板,直接ctrl+v粘贴即可 :)')
def main(): pyperclip.set_clipboard('xclip') srv = Service() print('Started DBus service at org.textsuggest.server, PID %d' % os.getpid()) srv.run()
def setup_boss_train_ddqn(self): self.analytics_client = AnalyticsClient(project_key="AISAAC_MONSTRO") input_mapping = { "W": ["w"], "A": ["a"], "S": ["s"], "D": ["d"], "WA": ["w", "a"], "WD": ["w", "d"], "SA": ["s", "a"], "SD": ["s", "d"], "UP": [self.input_controller.keyboard.up_key], "LEFT": [self.input_controller.keyboard.left_key], "DOWN": [self.input_controller.keyboard.down_key], "RIGHT": [self.input_controller.keyboard.right_key] } movement_action_space = KeyboardMouseActionSpace( directional_keys=[None, "W", "A", "S", "D", "WA", "WD", "SA", "SD"] ) projectile_action_space = KeyboardMouseActionSpace( projectile_keys=[None, "UP", "LEFT", "DOWN", "RIGHT"] ) model_file_path = "datasets/binding_of_isaac_rebirth_boss_1010_dqn_100000_0.1_.h5555" self.dqn_movement = DDQN( model_file_path=model_file_path if os.path.isfile(model_file_path) else None, input_shape=(67, 120, 4), input_mapping=input_mapping, action_space=movement_action_space, replay_memory_size=4000, max_steps=500000, observe_steps=4000, batch_size=64, initial_epsilon=1, final_epsilon=0.1, override_epsilon=False ) self.dqn_projectile = DDQN( model_file_path=model_file_path if os.path.isfile(model_file_path) else None, input_shape=(67, 120, 4), input_mapping=input_mapping, action_space=projectile_action_space, replay_memory_size=4000, max_steps=500000, observe_steps=4000, batch_size=64, initial_epsilon=1, final_epsilon=0.1, override_epsilon=False ) pyperclip.set_clipboard("xsel") pyperclip.copy(f"goto s.boss.{str(self.config['boss'])}")
def saveToClipboard(self, text): # ('Tkinter','osx','gtk','qt','xclip','xsel','klipper','windows') if self.clipboard == "Tkinter": print "saving to clipboard using Tkinter method" self.root.clipboard_clear() self.root.clipboard_append(text) else: print "saving to clipboard using xsel" pyperclip.set_clipboard(self.clipboard) pyperclip.copy(text)
def _ensure_clip_support(clipboard): if not pyperclip.is_available(): pyperclip.set_clipboard(clipboard) if not pyperclip.is_available(): print("Copy functionality unavailable!") print( '''On Linux, install xclip or xsel or klipper via package manager. For example, in Debian: sudo apt-get install xclip sudo apt-get install xsel ''') exit(1)
def __init__(self): self.has_primary = False if self._is_linux(): try: pyperclip.set_clipboard('xclip') log.debug("Set clipboard driver to xclip") self.has_primary = True except Exception as xclip_exception: try: pyperclip.set_clipboard('xsel') log.debug("Set clipboard driver to xclip") self.has_primary = True except Exception as xsel_exception: log.error( "Could not select a clipboard driver with primary selection. Errors:\n{}\n{}" .format(xclip_exception, xsel_exception))
def main(): if ('--version' in sys.argv) or ('-v' in sys.argv): print('textsuggest-server (TextSuggest) release 3.0.0 (build 3000)\n') print( '''Copyright © 2016-2018 Bharadwaj Raju, and others <https://github.com/bharadwaj-raju/TextSuggest/graphs/contributors>. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.''') return pyperclip.set_clipboard('xclip') srv = Service() print('Started DBus service at org.textsuggest.server, PID %d' % os.getpid()) srv.run()
def setup_maze_train_ddqn(self): self.analytics_client = AnalyticsClient(project_key="AISAAC_MAZE") plugin_path = offshoot.config["file_paths"]["plugins"] ocr_classifier_path = f"{plugin_path}/BindingOfIsaacRebirthGameAgentPlugin/files/ml_models/binding_of_isaac_rebirth_ocr.model" self.machine_learning_models["ocr_classifier"] = self.load_machine_learning_model(ocr_classifier_path) input_mapping = { "W": ["w"], "A": ["a"], "S": ["s"], "D": ["d"] } action_space = KeyboardMouseActionSpace( directional_keys=["W", "A", "S", "D"] ) model_file_path = "datasets/binding_of_isaac_rebirth_boss_1010_dqn_100000_0.1_.h5555" self.dqn = DDQN( model_file_path=model_file_path if os.path.isfile(model_file_path) else None, input_shape=(67, 120, 4), input_mapping=input_mapping, action_space=action_space, replay_memory_size=5000, max_steps=100000, observe_steps=500, batch_size=32, initial_epsilon=0.5, final_epsilon=0.01, override_epsilon=False ) pyperclip.set_clipboard("xsel") pyperclip.copy(f"luarun resources/scripts/aisaac.lua")
import pyperclip from . import desktop pyperclip.set_clipboard('xclip') def get(): return pyperclip.paste() def set(text, selection=False, notify=False, **kwargs): pyperclip.copy(text, primary=selection,) if notify: mode = 'selection' if selection else 'clipboard' desktop.notify('Copied to {}: {}'.format(mode, text), low=True, **kwargs) def set_and_notify(text, **kwargs): set(text) desktop.notify('Copied to clipboard: ' + text, **kwargs)
#!/bin/env python3 import argparse from os.path import basename, dirname, exists, expanduser, isdir, abspath from os import getcwd, system, mkdir, chdir, mknod, remove as rm, write, close, waitpid, fork, dup2, O_RDONLY, O_WRONLY, open as os_open, execv, pipe, setpgrp, wait, close, kill, read, set_inheritable, isatty, rename import sys, subprocess, re, json, argcomplete, pyperclip, tempfile, time from io import StringIO from glob import iglob, glob import collections import signal import resource, shlex, getpass pyperclip.set_clipboard("xsel") # For some reason my setup needs this ## Functions def editor_prompt(prompt_text, suffix=".txt"): fd, name = tempfile.mkstemp(suffix=suffix) write(fd, (prompt_text + "\n").encode("utf-8")) close(fd) system(config["editor"] + " " + name) with open(name, "r") as f: for i in range(prompt_text.count("\n") + 1): f.readline() input = f.read() rm(name) return input def dict_update(d, u): for k, v in u.items():
from pyperclip import copy,paste,set_clipboard set_clipboard('xsel') copy('hello')`
from tornado import websocket, web, ioloop import time from threading import Thread import sys import os from itertools import zip_longest try: from tornado.platform.asyncio import AnyThreadEventLoopPolicy import asyncio asyncio.set_event_loop_policy(AnyThreadEventLoopPolicy()) except: pass if os.name == 'posix': pyperclip.set_clipboard('xclip') clients = [] def remove_repetition(text, n): if len(text) % n != 0: return text output = [] args = [iter(text)] * n for group in zip_longest(*args): first_char = group[0] output.append(first_char) for c in group[1:]: if c != first_char:
def __init__(self, master, model): Tkinter.Toplevel.__init__(self, master=master) #self.minsize(600, 300) self.master = master self.title("Configure glyXtoolMS, and TOPPAS scripts") self.model = model self.columnconfigure(0, weight=1) self.rowconfigure(0, weight=0) self.rowconfigure(1, weight=0) self.rowconfigure(2, weight=0) self.rowconfigure(3, weight=0) self.rowconfigure(4, weight=1) self.columnconfigure(0, weight=1) frameOpenMS = ttk.Labelframe(self, text="OpenMS/TOPPAS Installation") frameOpenMS.grid(row=0, column=0, sticky="NWES") frameOpenMS.columnconfigure(0, weight=0) frameOpenMS.columnconfigure(3, weight=1) buttonOpenMS = Tkinter.Button(frameOpenMS, text="Set OpenMS Path", command=self.setOpenMSPath) buttonOpenMS.grid(row=0, column=0, sticky="NWES") self.openMSPathVar = Tkinter.StringVar() self.openMSPathVar.set(self.model.openMSDir) self.openMSPathEntry = Tkinter.Entry(frameOpenMS, textvariable=self.openMSPathVar, width=60) self.openMSPathEntry.grid(row=0, column=1, columnspan=3, sticky="NWES") self.openMSPathEntry.config(bg="white") self.openMSPathVar.trace("w", self.setTOPPASButtonState) self.buttonScripts = Tkinter.Button(frameOpenMS, text="Copy SCRIPTS into OpenMS", command=self.copyTOPPASFiles) self.buttonScripts.grid(row=1, column=1) self.buttonWorkflows = Tkinter.Button( frameOpenMS, text="Edit Scriptspath in TOPPAS Workflows", command=self.editWorkflows) self.buttonWorkflows.grid(row=1, column=2) #frameOutput = ttk.Labelframe(self, text="Set TOPPAS output folder") #frameOutput.grid(row=1, column=0, sticky="NWES") #frameOutput.columnconfigure(0, weight=0) #frameOutput.columnconfigure(1, weight=1) #buttonOutput = Tkinter.Button(frameOutput, text="Set TOPPAS output folder", command=self.setTOPPASOutput) #self.outputVar = Tkinter.StringVar() #self.outputVar.set(self.model.toppasOutputDir) #entryOutput = Tkinter.Entry(frameOutput, textvariable=self.outputVar, width=60) #entryOutput.config(bg="white") # #buttonOutput.grid(row=0, column=0, sticky="NWES") #entryOutput.grid(row=0, column=1, sticky="NWES") frameWorkspace = ttk.Labelframe(self, text="Set Workspace") frameWorkspace.grid(row=2, column=0, sticky="NWES") frameWorkspace.columnconfigure(0, weight=0) frameWorkspace.columnconfigure(1, weight=1) buttonWorkspace = Tkinter.Button(frameWorkspace, text="Set workspace", command=self.setWorkspace) self.workspaceVar = Tkinter.StringVar() self.workspaceVar.set(self.model.workingdir) entryWorkspace = Tkinter.Entry(frameWorkspace, textvariable=self.workspaceVar, width=60) entryWorkspace.config(bg="white") buttonWorkspace.grid(row=0, column=0, sticky="NWES") entryWorkspace.grid(row=0, column=1, sticky="NWES") frameTimeAxis = ttk.Labelframe(self, text="Timeaxis") frameTimeAxis.grid(row=3, column=0, sticky="NWES") self.timeAxisVar = Tkinter.StringVar() self.timeAxisVar.set(self.model.timescale) timeAxisChoice1 = Appearance.Radiobutton(frameTimeAxis, text="In seconds", variable=self.timeAxisVar, value="seconds") timeAxisChoice2 = Appearance.Radiobutton(frameTimeAxis, text="In minutes", variable=self.timeAxisVar, value="minutes") timeAxisChoice1.grid(row=0, column=0, sticky="NWS") timeAxisChoice2.grid(row=0, column=1, sticky="NWS") frameError = ttk.Labelframe(self, text="Mass Error") frameError.grid(row=4, column=0, sticky="NWES") self.errorVar = Tkinter.StringVar() self.errorVar.set(self.model.errorType) errorChoice1 = Appearance.Radiobutton(frameError, text="In Dalton", variable=self.errorVar, value="Da") errorChoice2 = Appearance.Radiobutton(frameError, text="In ppm", variable=self.errorVar, value="ppm") errorChoice1.grid(row=0, column=0, sticky="NWS") errorChoice2.grid(row=0, column=1, sticky="NWS") frameClipboard = ttk.Labelframe(self, text="Clipboard") frameClipboard.grid(row=5, column=0, sticky="NWES") self.clipVar = Tkinter.StringVar() self.clipVar.set(self.model.clipboard) boards = ('osx', 'qt', 'xclip', 'xsel', 'klipper', 'windows') # test which boards are available here avlBoards = [] for board in boards: try: pyperclip.set_clipboard(board) avlBoards.append(board) except: pass avlBoards = ['Tkinter'] + avlBoards for i, board in enumerate(avlBoards): clipboardChoice = Appearance.Radiobutton(frameClipboard, text=board, variable=self.clipVar, value=board) clipboardChoice.grid(row=5 + i / 3, column=1 + i % 3, sticky="NWS") frameDifferences = ttk.Labelframe(self, text="Massdifferences") frameDifferences.grid(row=6, column=0, sticky="NWES") scrollbar = Tkinter.Scrollbar(frameDifferences) self.tree = ttk.Treeview(frameDifferences, yscrollcommand=scrollbar.set, selectmode='browse') self.columns = ("Mass", "Charge", "Type") self.tree["columns"] = self.columns self.tree.grid(row=0, column=0, sticky="NWES") self.tree["columns"] = self.columns self.tree.heading("#0", text="Name", command=lambda col="#0": self.sortColumn(col)) for col in self.columns: self.tree.heading(col, text=col, command=lambda col=col: self.sortColumn(col)) scrollbar.grid(row=0, column=1, sticky="NWES") scrollbar.config(command=self.tree.yview) self.tree.bind("<<TreeviewSelect>>", self.clickedTree) frameEntry = ttk.Labelframe(frameDifferences, text="Entry") frameEntry.grid(row=0, column=2, sticky="NWE") l1 = ttk.Label(frameEntry, text="Name:") l2 = ttk.Label(frameEntry, text="Mass:") l3 = ttk.Label(frameEntry, text="Charge:") l4 = ttk.Label(frameEntry, text="Type:") l1.grid(row=0, column=0, sticky="NW") l2.grid(row=1, column=0, sticky="NW") l3.grid(row=2, column=0, sticky="NW") l4.grid(row=3, column=0, sticky="NW") self.v1 = Tkinter.StringVar() self.v2 = Tkinter.StringVar() self.v3 = Tkinter.StringVar() self.v4 = Tkinter.StringVar() self.v1.trace("w", lambda a, b, c: self.valueChanged("v1")) self.v2.trace("w", lambda a, b, c: self.valueChanged("v2")) self.v3.trace("w", lambda a, b, c: self.valueChanged("v3")) self.v4.trace("w", lambda a, b, c: self.valueChanged("v4")) self.e1 = Tkinter.Entry(frameEntry, textvariable=self.v1) self.e2 = Tkinter.Entry(frameEntry, textvariable=self.v2) self.e3 = Tkinter.Entry(frameEntry, textvariable=self.v3) self.e4 = Tkinter.Entry(frameEntry, textvariable=self.v4) self.e1.grid(row=0, column=1, sticky="NW") self.e2.grid(row=1, column=1, sticky="NW") self.e3.grid(row=2, column=1, sticky="NW") self.e4.grid(row=3, column=1, sticky="NW") self.e1.config(bg="white") self.e2.config(bg="white") self.e3.config(bg="white") self.e4.config(bg="white") frameEntry2 = ttk.Frame(frameEntry) frameEntry2.grid(row=4, column=0, columnspan=2, sticky="NWES") self.b1 = Tkinter.Button(frameEntry2, text="Delete Entry", command=self.deleteEntry) self.b2 = Tkinter.Button(frameEntry2, text="New Entry", command=self.newEntry) self.b1.grid(row=0, column=0, sticky="SW") self.b2.grid(row=0, column=1, sticky="SE") # add data for mass, name, charge, typ in self.model.massdifferences: self.tree.insert("", "end", text=name, values=(str(round(mass, 4)), str(charge), typ)) self.sorting = ("#0", False) frameButtons = ttk.Frame(self) frameButtons.grid(row=7, column=0, sticky="NWES") cancelButton = Tkinter.Button(frameButtons, text="Cancel", command=self.cancel) self.saveButton = Tkinter.Button(frameButtons, text="Save options", command=self.save) cancelButton.grid(row=0, column=0, sticky="NWES") self.saveButton.grid(row=0, column=1, sticky="NWES") # run OpenMS Check self.setTOPPASButtonState() self.model.centerWidget(self.master, self)
def setup_play(self): input_mapping = { "W": [KeyboardKey.KEY_W], "A": [KeyboardKey.KEY_A], "S": [KeyboardKey.KEY_S], "D": [KeyboardKey.KEY_D], "WA": [KeyboardKey.KEY_W, KeyboardKey.KEY_A], "WD": [KeyboardKey.KEY_W, KeyboardKey.KEY_D], "SA": [KeyboardKey.KEY_S, KeyboardKey.KEY_A], "SD": [KeyboardKey.KEY_S, KeyboardKey.KEY_D], "UP": [KeyboardKey.KEY_UP], "LEFT": [KeyboardKey.KEY_LEFT], "DOWN": [KeyboardKey.KEY_DOWN], "RIGHT": [KeyboardKey.KEY_RIGHT] } self.key_mapping = { KeyboardKey.KEY_W.name: "MOVE UP", KeyboardKey.KEY_A.name: "MOVE LEFT", KeyboardKey.KEY_S.name: "MOVE DOWN", KeyboardKey.KEY_D.name: "MOVE RIGHT", KeyboardKey.KEY_UP.name: "SHOOT UP", KeyboardKey.KEY_LEFT.name: "SHOOT LEFT", KeyboardKey.KEY_DOWN.name: "SHOOT DOWN", KeyboardKey.KEY_RIGHT.name: "SHOOT RIGHT", } movement_action_space = KeyboardMouseActionSpace(directional_keys=[ None, "W", "A", "S", "D", "WA", "WD", "SA", "SD" ]) projectile_action_space = KeyboardMouseActionSpace( projectile_keys=[None, "UP", "LEFT", "DOWN", "RIGHT"]) movement_model_file_path = "datasets/binding_of_isaac_movement_dqn_0_1_.h5".replace( "/", os.sep) self.dqn_movement = DDQN( model_file_path=movement_model_file_path if os.path.isfile(movement_model_file_path) else None, input_shape=(100, 100, 4), input_mapping=input_mapping, action_space=movement_action_space, replay_memory_size=5000, max_steps=1000000, observe_steps=1000, batch_size=32, initial_epsilon=1, final_epsilon=0.01, override_epsilon=False) projectile_model_file_path = "datasets/binding_of_isaac_projectile_dqn_0_1_.h5".replace( "/", os.sep) self.dqn_projectile = DDQN( model_file_path=projectile_model_file_path if os.path.isfile(projectile_model_file_path) else None, input_shape=(100, 100, 4), input_mapping=input_mapping, action_space=projectile_action_space, replay_memory_size=5000, max_steps=1000000, observe_steps=1000, batch_size=32, initial_epsilon=1, final_epsilon=0.01, override_epsilon=False) if sys.platform in ["linux", "linux2"]: pyperclip.set_clipboard("xsel") pyperclip.copy(f"goto s.boss.{self.bosses['MONSTRO']}")
#!/usr/bin/env python import socket import threading import time import pyperclip import traceback import daemon import sys perip = open('config.ini').readline().strip() print perip port = 9999 #important ! if not set ,daemon can't call paste copy correct pyperclip.set_clipboard('xsel') clipdata = pyperclip.paste() def tcplink(sock, addr): global clipdata print 'Accept new connection from %s:%s...' % addr while True: data = sock.recv(1024 * 10) time.sleep(1) if data == 'exit' or not data: break #sock.send('Hello,%s!'%data) print "%s - %s" % ("recv", data) try: pyperclip.copy(data) clipdata = data except Exception as e:
def _ensure_clipboard_backend(): """ CommandLine: pip install pyperclip sudo apt-get install xclip sudo apt-get install xsel pip install python-qt5 # for windows conda install pyqt References: http://stackoverflow.com/questions/11063458/-text-to-clipboard http://stackoverflow.com/questions/579687using-python Ignore: import pyperclip # Qt is by far the fastest, followed by xsel, and then xclip backend_order = ['xclip', 'xsel', 'qt', 'gtk'] backend_order = ['qt', 'xsel', 'xclip', 'gtk'] for be in backend_order: print('be = %r' % (be,)) pyperclip.set_clipboard(be) %timeit pyperclip.copy('a line of reasonable length text') %timeit pyperclip.paste() CommandLine: python -m vimtk.xctrl _ensure_clipboard_backend Example: >>> from vimtk.xctrl import * # NOQA >>> result = _ensure_clipboard_backend() >>> prev = get_clipboard() >>> text1 = 'foobar' >>> text2 = 'bazbiz' >>> copy_text_to_clipboard(text1) >>> pasted1 = get_clipboard() >>> copy_text_to_clipboard(text2) >>> pasted2 = get_clipboard() >>> assert pasted1 == text1 >>> assert pasted2 == text2 >>> copy_text_to_clipboard(prev) """ if getattr(pyperclip, '_vimtk_monkey_backend', 'no') != 'no': return def _check_clipboard_backend(backend): if backend == 'windows': return sys.platform.startswith('win32') if backend == 'qt': return (ub.modname_to_modpath('PyQt5') or ub.modname_to_modpath('PyQt4')) elif backend == 'gtk': return ub.modname_to_modpath('gtk') else: return pyperclip._executable_exists(backend) if ub.WIN32: backend_order = ['windows', 'qt'] else: backend_order = ['xclip', 'xsel', 'qt', 'gtk'] #raise NotImplementedError('not on windows yet') for backend in backend_order: if _check_clipboard_backend(backend): if pyperclip is None: raise Exception( 'pyperclip is not appear to be installed. ' 'See also: https://github.com/Erotemic/vimtk/issues/5') pyperclip.set_clipboard(backend) pyperclip._vimtk_monkey_backend = backend return else: print('warning %r not installed' % (backend, ))
def __init__(self): self._memcache = memcache.Client(['10.96.80.111:11211'], debug=0) self._memo = None # initialize our clipboard settings pyperclip.set_clipboard('klipper')