Skip to content

Instantly share code, notes, and snippets.

View bolin-hsu's full-sized avatar

Bolin Hsu bolin-hsu

View GitHub Profile
@bolin-hsu
bolin-hsu / gist:0e1e1c5baa7cf806b92c
Last active August 29, 2015 14:05
MySQL cleanup script
#!/usr/bin/env python
from datetime import datetime
import mysql.connector
from itertools import chain
import time
class MySQL:
def __init__(self):
self.connector = mysql.connector.connect(
user='usr',
@bolin-hsu
bolin-hsu / gist:0d92e68ef1943b08f8b6
Last active August 29, 2015 14:05
MySQL utility class
class MySQL:
def __init__(self):
self.connector = mysql.connector.connect(
user='usr',
password='pwd',
host='127.0.0.1',
port='20033', # tunnel to server
database='db')
self.cursor = self.connector.cursor()
for s in remote1 remote2 ... remote87
do
ssh $s ls -lrt /var/lib/jelli/audio-recording/ | tail -1
done
$ ssh remote ls -lrt /mnt/data/ | tail -1
#!/usr/bin/env python
import argparse
import subprocess
def check_one_station(station):
cmd = 'ssh {0} ls -alrt /var/lib/jelli/audio-recording/ | grep -v ^d | tail -1'.format(station)
p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(out, err) = p.communicate()
idx = err.find('cannot access')
if idx >= 0:
#!/usr/bin/env python
import argparse
import subprocess
import threading
import Queue
import string
import time
class CheckOneStation(threading.Thread):
_err_marker = '###'