Commits

jodoherty  committed d2983d3

Deployed site backup repo.

  • Participants

Comments (0)

Files changed (1038)

+__pycache__
+config.ini
+config.py
+*.pyc
+lib
+tcache
+bin
+autostart.cgi
+pid
+
+create table users (
+  id integer primary key,
+  username text,
+  password text,
+  email text,
+  profile text,
+  confirmed integer,
+  regdate text
+);
+
+create table comments (
+  id integer primary key,
+  track_id integer,
+  author text,
+  message text,
+  date text
+);
+
+create table samples (
+  id integer primary key,
+  name text,
+  instrument text,
+  game text
+);
+
+create table tracks (
+  id integer primary key,
+  bid text,
+  title text,
+  artist text,
+  date text,
+  last_modified text,
+  last_finished text,
+  body text,
+  finished boolean
+);

File data/metainfo.db

Binary file added.

File mmlsharedb_sqlite.py

+import sqlite3
+import datetime,time
+import sha
+
+def hash_password(password):
+  return sha.sha(password).hexdigest()
+def convert_date(date_string):
+  if not date_string:
+    return None
+  return datetime.datetime.strptime(date_string, "%Y-%m-%dT%H:%M:%S.%f")
+def dict_factory(cursor, row):
+    d = {}
+    for idx, col in enumerate(cursor.description):
+        d[col[0]] = row[idx]
+    return d
+class DB:
+  def __init__(self):
+    self.opened = False
+  def open(self):
+    if not self.opened:
+      self.conn = sqlite3.connect('data/metainfo.db',
+          detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
+      self.conn.row_factory = dict_factory
+      self.opened = True
+  def close(self):
+    if self.opened:
+      self.conn.commit()
+      self.conn.close()
+      self.opened = False
+  def get_cursor(self):
+    if not self.opened:
+      self.open()
+    return self.conn.cursor()
+  def hash_password(self, password):
+    return hash_password(password)
+  # Users
+  def make_user(self, row):
+    if row:
+      return {'user_id': int(row['id']),
+              '_id': row['id'],
+              'username': row['username'],
+              'password': row['password'],
+              'email': row['email'],
+              'profile': row['profile'],
+              'confirmed': row['confirmed'] == 1,
+              'regdate': convert_date(row['regdate']) }
+    return None
+  def username_exists(self, username):
+    return self.get_user_ic(username) != None
+  def get_user_by_id(self, user_id):
+    if user_id == None:
+      return None
+    try:
+      self.open()
+      rows = self.conn.execute("select * from users where id = ?", [int(user_id)])
+      for row in rows:
+        return self.make_user(row)
+      return None
+    finally:
+      self.close()
+  def get_user_ic(self, username):
+    try:
+      self.open()
+      rows = self.conn.execute("select * from users where username = ?", [username])
+      for row in rows:
+        return self.make_user(row)
+      return None
+    finally:
+      self.close()
+  def add_user(self, user):
+    try:
+      self.open()
+      values     = [user['username'],
+                    user['password'],
+                    user['email'],
+                    user['profile'],
+                    user['confirmed'],
+                    user['regdate']]
+      c = self.conn.cursor()
+      res = c.execute("""insert into users (username, password, email, 
+                            profile, confirmed, regdate)
+                          values (?, ?, ?, ?, ?, ?)""", values)
+      c.close()
+      return res
+    finally:
+      self.close()
+  def verify_user(self, username, password):
+    user = self.get_user_ic(username)
+    if not user:
+      return False
+    return user['password'] == hash_password(password)
+  # Samples
+  def make_sample(self, row):
+    if row:
+      return {'id': int(row['id']),
+              '_id': row['id'],
+              'name': row['name'],
+              'game': row['game'],
+              'instrument': row['instrument'] }
+    return None
+  def add_sample(self, **kargs):
+    try:
+      self.open()
+      values = [kargs['name'], kargs['game'], kargs['instrument']]
+      return self.conn.execute("""insert into samples (name, game, instrument)
+                                  values(?,?,?)""", values)
+    finally:
+      self.close()
+  def get_sample(self, name):
+    try:
+      self.open()
+      rows = self.conn.execute("select * from samples where name = ?", [name])
+      for row in rows:
+        return self.make_sample(row)
+    finally:
+      self.close()
+  def get_sample_games(self):
+    try:
+      self.open()
+      rows = self.conn.execute("select distinct game from samples")
+      games = [row['game'] for row in rows]
+      return games
+    finally:
+      self.close()
+  def get_sample_instruments(self):
+    try:
+      self.open()
+      rows = self.conn.execute("select distinct instrument from samples")
+      instruments = [row['instrument'] for row in rows]
+      return instruments
+    finally:
+      self.close()
+  def get_samples(self, games=[], instruments=[]):
+    try:
+      self.open()
+      samples = []
+      for game in games:
+        rows = self.conn.execute("select * from samples where game = ?", [game])
+        samples += [self.make_sample(row) for row in rows]
+      for instrument in instruments:
+        rows = self.conn.execute("select * from samples where instrument = ?", [instrument])
+        samples += [self.make_sample(row) for row in rows]
+      if (not games) and (not instruments):
+        rows = self.conn.execute("select * from samples")
+        samples = [self.make_sample(row) for row in rows]
+      return samples
+    finally:
+      self.close()
+  # Tracks
+  def count_tracks(self, artist=None, finished=False):
+    try:
+      self.open()
+      if artist:
+        rows = self.conn.execute("""SELECT count(*) as count from tracks
+                                    where artist = ?""", [artist])
+      else: 
+        rows = self.conn.execute("""SELECT count(*) as count from tracks
+                                    where finished = ?""", [int(finished)])
+      for row in rows:
+        return int(row['count'])
+    finally:
+      self.close()
+  def get_tracks(self, offset=0, limit=20, order='date', artist=None, finished=False):
+    try:
+      self.open()
+      rows = []
+      if artist:
+        rows = self.conn.execute("""SELECT * from tracks where 
+                                    artist = ?
+                                    ORDER BY last_modified DESC LIMIT ?,?""", 
+                                   [artist, offset, limit])
+      elif finished:
+        rows = self.conn.execute("""SELECT * from tracks where finished = ?
+                                    ORDER BY last_finished DESC LIMIT ?,?""", 
+                                   [int(finished), offset, limit])
+      else:
+        rows = self.conn.execute("""SELECT * from tracks where finished = ?
+                                    ORDER BY last_modified DESC LIMIT ?,?""", 
+                                   [int(finished), offset, limit])
+      tracks = [dict(row) for row in rows]
+      for track in tracks:
+        track['date'] = convert_date(track['date'])
+        track['last_modified'] = convert_date(track['last_modified'])
+        track['last_finished'] = convert_date(track['last_finished'])
+      return tracks
+    finally:
+      self.close()
+  def get_track(self, track_id):
+    try:
+      self.open()
+      if type(track_id) == type(1) or len(track_id) < 10:
+        track_id = int(track_id)
+        rows = self.conn.execute("""SELECT * from tracks where id = ?""",
+                                 [track_id])
+      else:
+        rows = self.conn.execute("""SELECT * from tracks where bid = ?""",
+                                 [track_id])
+      track = {}
+      for row in rows:
+        track = dict(row)
+      return track
+    finally:
+      self.close()
+  def remove_track(self, track_id):
+    try:
+      self.open()
+      self.conn.execute("DELETE from tracks where id = ?",
+                        [track_id])
+      self.conn.execute("DELETE from comments where track_id = ?",
+                        [track_id])
+    finally:
+      self.close()
+  def create_track(self, track):
+    try:
+      self.open()
+      c = self.conn.cursor()
+      c.execute("""INSERT into tracks (title, artist, body, date, last_modified, finished)
+                   values (?,?,?,?,?,0)""",
+                        [track['title'], track['artist'], track['body'],
+                         datetime.datetime.now().isoformat(),
+                         datetime.datetime.now().isoformat()])
+      tid = c.lastrowid
+      return tid
+    finally:
+      c.close()
+      self.close()
+  def update_track(self, track_id, track):
+    try:
+      self.open()
+      self.conn.execute("""UPDATE tracks 
+                           set title = ?,
+                               artist = ?,
+                               date = ?,
+                               last_modified = ?,
+                               last_finished = ?,
+                               body = ?,
+                               finished = ?
+                           where id = ?""",
+                        [track['title'],
+                         track['artist'],
+                         track['date'],
+                         track['last_modified'],
+                         track['last_finished'],
+                         track['body'],
+                         track['finished'],
+                         int(track_id)])
+    finally:
+      self.close()
+  # Comments
+  def get_comments(self, track_id):
+    try:
+      self.open()
+      rows = self.conn.execute("SELECT * from comments where track_id = ?", [track_id])
+      comments = [dict(row) for row in rows]
+      for comment in comments:
+        comment['date'] = convert_date(comment['date'])
+      return comments
+    finally:
+      self.close()
+  def add_comment(self, track_id, comment):
+    try:
+      self.open()
+      self.conn.execute("""INSERT into comments (track_id, author, 
+                                    message, date) VALUES(?,?,?,?)""",
+                        [track_id, comment['author'], comment['message'], comment['date']])
+    finally:
+      self.close()
+  def get_recent_comments(self, user):
+    try:
+      self.open()
+      rows = self.conn.execute("""SELECT tracks.id as track_id, 
+                                         tracks.title as track_title,
+                                         comments.author as author, 
+                                         comments.message as message,
+                                         comments.date as date
+                                  FROM tracks, comments
+                                  WHERE tracks.artist = ?
+                                    AND tracks.id = comments.track_id
+                                  ORDER BY comments.date DESC
+                                  LIMIT 0,30""",
+                               [user])
+      return [dict(row) for row in rows]
+    finally:
+      self.close()
+

File samples/AkumajouDensetsu_$C000.dmc

Binary file added.

File samples/AkumajouDensetsu_$C040.dmc

Binary file added.

File samples/AkumajouDensetsu_$C240.dmc

Binary file added.

File samples/AkumajouDensetsu_$C900.dmc

Binary file added.

File samples/Andonuts/scorchosnare.dmc

Binary file added.

File samples/BuckyOHare_$FE00.dmc

Binary file added.

File samples/BuckyOHare_$FF40.dmc

Binary file added.

File samples/Bun/sep_orch.dmc.dmc

Binary file added.

File samples/Bun/sep_timp_1.dmc.dmc

Binary file added.

File samples/Bun/sep_timp_1_10.dmc.dmc

Binary file added.

File samples/Bun/sep_timp_1_20.dmc.dmc

Binary file added.

File samples/Bun/sep_timp_1_roll.dmc.dmc

Binary file added.

File samples/Bun/sep_timp_2.dmc.dmc

Binary file added.

File samples/CrisisForce_$C040.dmc

Binary file added.

File samples/CrisisForce_$C240.dmc

Binary file added.

File samples/CrisisForce_$C540.dmc

Binary file added.

File samples/EsperDream2_$E000.dmc

Binary file added.

File samples/EsperDream2_$E140.dmc

Binary file added.

File samples/EsperDream2_$E1C0.dmc

Binary file added.

File samples/FestersQuest_$C000.dmc

Binary file added.

File samples/FestersQuest_$C200.dmc

Binary file added.

File samples/FestersQuest_$C400.dmc

Binary file added.

File samples/FestersQuest_$C600.dmc

Binary file added.

File samples/FestersQuest_$C800.dmc

Binary file added.

File samples/FestersQuest_$CC00.dmc

Binary file added.

File samples/FinalMission_$FC80.dmc

Binary file added.

File samples/FinalMission_$FD40.dmc

Binary file added.

File samples/FireNIce_$C000.dmc

Binary file added.

File samples/FireNIce_$C1C0.dmc

Binary file added.

File samples/FireNIce_$C380.dmc

Binary file added.

File samples/FireNIce_$C540.dmc

Binary file added.

File samples/FireNIce_$C700.dmc

Binary file added.

File samples/FireNIce_$C8C0.dmc

Binary file added.

File samples/FireNIce_$CA80.dmc

Binary file added.

File samples/FireNIce_$CC40.dmc

Binary file added.

File samples/FireNIce_$CE00.dmc

Binary file added.

File samples/FireNIce_$CFC0.dmc

Binary file added.

File samples/FireNIce_$D180.dmc

Binary file added.

File samples/FireNIce_$D340.dmc

Binary file added.

File samples/FireNIce_$D500.dmc

Binary file added.

File samples/FireNIce_$D6C0.dmc

Binary file added.

File samples/FireNIce_$D880.dmc

Binary file added.

File samples/FireNIce_$DA40.dmc

Binary file added.

File samples/FireNIce_$DC00.dmc

Binary file added.

File samples/FireNIce_$DE40.dmc

+���:�$�G

File samples/Gimmick_$C400.dmc

Binary file added.

File samples/Gimmick_$C500.dmc

Binary file added.

File samples/Gimmick_$C600.dmc

Binary file added.

File samples/Gimmick_$C800.dmc

Binary file added.

File samples/Gimmick_$CA00.dmc

Binary file added.

File samples/Gimmick_$CC00.dmc

Binary file added.

File samples/Gimmick_$CF00.dmc

Binary file added.

File samples/Gimmick_$D000.dmc

Binary file added.

File samples/Gimmick_$D200.dmc

Binary file added.

File samples/Gimmick_$D300.dmc

Binary file added.

File samples/Gimmick_$D700.dmc

Binary file added.

File samples/Gimmick_$D800.dmc

Binary file added.

File samples/GradiusII_$C000.dmc

Binary file added.

File samples/GradiusII_$C140.dmc

Binary file added.

File samples/GradiusII_$C280.dmc

Binary file added.

File samples/GradiusII_$C340.dmc

Binary file added.

File samples/GradiusII_$C640.dmc

Binary file added.

File samples/Gremlins2_$C000.dmc

Binary file added.

File samples/Gremlins2_$C200.dmc

Binary file added.

File samples/Gremlins2_$C600.dmc

Binary file added.

File samples/Gremlins2_$CA00.dmc

Binary file added.

File samples/Gremlins2_$CE00.dmc

Binary file added.

File samples/Gremlins2_$D200.dmc

Binary file added.

File samples/Gremlins2_$D600.dmc

Binary file added.

File samples/Gyruss_$E000.dmc

Binary file added.

File samples/HeavyShred_$C480.dmc

Binary file added.

File samples/HeavyShred_$C600.dmc

Binary file added.

File samples/HeavyShred_$C880.dmc

Binary file added.

File samples/HeavyShred_$CBC0.dmc

Binary file added.

File samples/HeavyShred_$CC80.dmc

Binary file added.

File samples/HeavyShred_$CFC0.dmc

Binary file added.

File samples/Immortal_$FB00.dmc

Binary file added.

File samples/Immortal_$FE00.dmc

Binary file added.

File samples/Jackal_$C000.dmc

Binary file added.

File samples/Jackal_$C0C0.dmc

Binary file added.

File samples/Jophish/kick.dmc

Binary file added.

File samples/Jophish/snare.dmc

Binary file added.

File samples/Journey_$C000.dmc

Binary file added.

File samples/Journey_$C400.dmc

Binary file added.

File samples/Journey_$C800.dmc

Binary file added.

File samples/Journey_$CC00.dmc

Binary file added.

File samples/Journey_$D000.dmc

Binary file added.

File samples/JurassicPark_$E700.dmc

Binary file added.

File samples/JurassicPark_$E840.dmc

Binary file added.

File samples/KickMaster_$C000.dmc

Binary file added.

File samples/KickMaster_$C200.dmc

Binary file added.

File samples/Kirby_$FC00.dmc

Binary file added.

File samples/Kirby_$FCC0.dmc

Binary file added.

File samples/Kirby_$FE80.dmc

Binary file added.

File samples/Kirby_$FF40.dmc

Binary file added.

File samples/LagrangePoint_$FE00.dmc

Binary file added.

File samples/LagrangePoint_$FF40.dmc

Binary file added.

File samples/MetalMax_$C000.dmc

Binary file added.

File samples/MetalMax_$C100.dmc

Binary file added.

File samples/MetalMax_$C3C0.dmc

Binary file added.

File samples/MetalMax_$C680.dmc

File samples/MetalMax_$CAC0.dmc

Binary file added.

File samples/MetalMax_$CC80.dmc

Binary file added.

File samples/MetalMax_$CE00.dmc

Binary file added.

File samples/Mex/kirby_snare.dmc

Binary file added.

File samples/Mex/kkick.dmc

Binary file added.

File samples/Mex/ksnare.dmc

Binary file added.

File samples/Mex/smb2_congo.dmc

Binary file added.

File samples/Mex/strobe kick.dmc

Binary file added.

File samples/Mex/strobe snare.dmc

Binary file added.

File samples/MonsterIMP_$C000.dmc

Binary file added.

File samples/MonsterIMP_$C1C0.dmc

Binary file added.

File samples/MonsterIMP_$C340.dmc

Binary file added.

File samples/MonsterIMP_$C4C0.dmc

Binary file added.

File samples/NinjaGaiden2_$FC00.dmc

Binary file added.

File samples/NinjaGaiden2_$FE00.dmc

Binary file added.