Skip to content

Commit b3ae7d3

Browse files
committed
Auto upload
1 parent c825ea0 commit b3ae7d3

File tree

8 files changed

+71
-66
lines changed

8 files changed

+71
-66
lines changed

clicker/__main__.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
'''
2-
Windows only
2+
Windows only.
3+
Use your phone to send UP and DOWN to your computer!
4+
Useful for reading in Kindle.
5+
6+
WARNING: Running this may open vulnerabilities for your computer.
7+
Don't run this if you don't know what you are doing.
8+
Only run this if you are in a safe network, or inside a firewall.
9+
I am not responsible if someone attacks your computer through this server.
310
'''
411
print('Loading...')
512
import keyboard

console/__init__.py

+41-22
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
'''
1111
import platform
1212
from interactive import listen, strCommonStart
13-
from kernal import Kernal
13+
from .kernal import Kernal
1414
from graphic_terminal import clearLine
1515
import string
1616

@@ -82,28 +82,18 @@ def console(namespace = {}, prompt = '>>> ', use_input = False, fixer = None):
8282
elif op == b'\xe0O':
8383
cursor = len(command)
8484
elif op == b'\xe0s': # Ctrl Left
85-
word_started = False
86-
for cursor in range(cursor - 1, -1, -1):
87-
if command[cursor].isalpha():
88-
word_started = True
89-
else:
90-
if word_started:
91-
cursor += 1
92-
break
85+
cursor = wordStart(command, cursor)
9386
elif op == b'\xe0t': # Ctrl Right
94-
word_started = False
95-
word_ended = False
96-
for cursor in range(cursor, len(command)):
97-
if command[cursor].isalpha():
98-
if word_ended:
99-
break
100-
else:
101-
word_started = True
102-
else:
103-
if word_started:
104-
word_ended = True
105-
else:
106-
cursor = len(command)
87+
cursor = wordEnd(command, cursor)
88+
elif op == b'\x7f': # Ctrl Backspace
89+
old_cursor = cursor
90+
cursor = wordStart(command, cursor)
91+
command = command[:cursor] + command[old_cursor:]
92+
elif op == b'\xe0\x93': # Ctrl Del
93+
old_cursor = cursor
94+
cursor = wordEnd(command, cursor)
95+
command = command[:old_cursor] + command[cursor:]
96+
cursor = old_cursor
10797
elif op == b'\t':
10898
# auto complete
10999
legal_prefix = string.ascii_letters + string.digits + '_'
@@ -166,3 +156,32 @@ def console(namespace = {}, prompt = '>>> ', use_input = False, fixer = None):
166156
next(kernal)
167157
if result is not None:
168158
print(result)
159+
160+
def wordStart(command, cursor):
161+
word_started = False
162+
i = cursor
163+
for i in range(cursor - 1, -1, -1):
164+
if command[i].isalpha():
165+
word_started = True
166+
else:
167+
if word_started:
168+
i += 1
169+
break
170+
return i
171+
172+
def wordEnd(command, cursor):
173+
word_started = False
174+
word_ended = False
175+
i = cursor
176+
for i in range(cursor, len(command)):
177+
if command[i].isalpha():
178+
if word_ended:
179+
break
180+
else:
181+
word_started = True
182+
else:
183+
if word_started:
184+
word_ended = True
185+
else:
186+
i = len(command)
187+
return i

pickle_socket.py

+11-41
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55
import pickle
66
from io import BytesIO
77
import sys
8-
__all__ = ['PickleSocket', 'RemoteClosedUnexpectedly']
8+
__all__ = ['PickleSocket', 'RemoteClosedDuringPickle']
99

1010
class PickleSocket():
1111
def __init__(self,upon_this_socket=None):
1212
if upon_this_socket is None:
1313
self.socket=socket.socket()
1414
else:
1515
self.socket=upon_this_socket
16+
for name in dir(self.socket):
17+
if name[:2] != '__':
18+
self.__setattr__(name, self.socket.__getattribute__(name))
1619

1720
def shakeHands(self,banner='This is a pickleSocket by Daniel Chin. ',echo=True):
1821
self.sendObj(banner)
@@ -27,29 +30,6 @@ def shakeHands(self,banner='This is a pickleSocket by Daniel Chin. ',echo=True):
2730
input('Enter to exit...')
2831
sys.exit(1)
2932

30-
def bind(self,address,local=False):
31-
'''
32-
if `local` is True, address is no longer a tuple, but a port int.
33-
'''
34-
if local:
35-
self.socket.bind(('127.0.0.1',address))
36-
else:
37-
self.socket.bind(address)
38-
39-
def listen(self,capacity):
40-
self.socket.listen(capacity)
41-
42-
def connect(self,address,AB=False,dorm=False,local=False):
43-
'''if AB or dorm is True, address is no longer a tuple, but a port int.'''
44-
if AB:
45-
self.socket.connect(('10.209.1.45',address))
46-
elif dorm:
47-
self.socket.connect(('10.209.23.186',address))
48-
elif local:
49-
self.socket.connect(('127.0.0.1',address))
50-
else:
51-
self.socket.connect(address)
52-
5333
def sendObj(self,obj):
5434
io_obj=BytesIO()
5535
pickle.dump(obj,io_obj)
@@ -61,20 +41,6 @@ def sendObj(self,obj):
6141

6242
def recvObj(self):
6343
return pickle.load(IoSocket(self.socket))
64-
65-
def send(self,*args):
66-
return self.socket.send(*args)
67-
68-
def recv(self,*args):
69-
return self.socket.recv(*args)
70-
71-
def accept(self):
72-
s,addr=self.socket.accept()
73-
s=self.__class__(s)
74-
return s,addr
75-
76-
def close(self):
77-
return self.socket.close()
7844

7945
class IoSocket:
8046
def __init__(self,socket):
@@ -83,8 +49,8 @@ def __init__(self,socket):
8349
def read(self,count=1):
8450
read=self.socket.recv(count)
8551
if read==b'':
86-
raise RemoteClosedUnexpectedly
87-
return read
52+
raise RemoteClosedDuringPickle
53+
return read
8854

8955
def readline(self):
9056
read=b''
@@ -94,5 +60,9 @@ def readline(self):
9460
buffer+=read
9561
return buffer
9662

97-
class RemoteClosedUnexpectedly(BaseException):
63+
class RemoteClosedDuringPickle(BaseException):
9864
pass
65+
66+
if __name__ == '__main__':
67+
from console import console
68+
console(globals())

pimport.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
'''
2+
pip install, and imports
3+
'''
14
import pip
25

36
def pimport(name):

playwav.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
'''
2+
Light-weight wav player.
3+
'''
14
import sys
25
import simpleaudio as sa
36
from os import path

prime.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'''
2-
This is to be imported.
2+
Get prime numbers
33
'''
44
import numpy
55

stats.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
'''
2+
What I learned from Statistics for Business and Finance.
3+
'''
14
dict_Z = {.05 : 1.645,
25
.025 : 1.96,
36
.01 : 2.326,

tree.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'''
2-
Data type that stores directory structure.
2+
Data type that stores file directory structure.
33
'''
44
import os
55

0 commit comments

Comments
 (0)