Archive for the ‘linux’ category

Torrent Linker: Update

October 29th, 2010

A while ago I came up with a python script to link torrent newly downloaded torrent files to a folder allowing you to manage data more effectively whilst seeding. However I have only just realised that the initial script does not work as the importer appears to have removed the spaces at the start of each line making the code unusable. As I cannot find my original code here is an update that also features a twitter integration to send you a twitter message when a file has completed.

All you have to do is modify the items inside of “Modify These Variables”, also ensure to set your torrent program to move your completed torrents to the ‘torrentfilesdirectory’ folder

import os
import sys
from commands import getoutput

#Declare Variables
ary_errors    = []
ary_directory = []
ary_tracker   = []
ary_torrent   = []

#Modify These Variables
torrentfilesdirectory = "/torrent/torrentfilescompleted/"
torrent_completed_dir = "/torrent/completed/"
link_directory        = "/torrent/links/"
torrent_move_to_dir   = "/torrent/torrentfilescompletedandlinked/"
twitter_username      = "##########"
twitter_password      = "##########"

#Add list of torrents into variable
torrent_list = getoutput("ls " + torrentfilesdirectory)

#=====================================================
def WorkOnTorrents(line):
 #Read data from torrent
 directory = getoutput("btshowmetainfo \"" + torrentfilesdirectory + line + "\" | grep \"directory name:\"")
 directory = directory + getoutput("btshowmetainfo \"" + torrentfilesdirectory + line + "\" | grep \"file name.....:\"")
 tracker = getoutput("btshowmetainfo \"" + torrentfilesdirectory + line + "\" | grep \"announce url..:\"")

 #Modify the directory variable
 directory = directory.split(": ")[1]

 #Modify the tracker variable
 try:
  tracker = tracker.split("\n")[0].split("/")[2].split(":")[0]
  torrent_valid = "Works"
 except:
  torrent_valid = "Fails"

 print tracker;

 #Add torrent variables to arrays
 if torrent_valid == "Works":
  # Check Against Identified Errors
  if tracker == "":
   ary_errors.append(line);
  else:
   ary_tracker.append(tracker);
   ary_directory.append(directory);
   ary_torrent.append(line);

torrent_list = torrent_list.split("\n")
for line in torrent_list:
 WorkOnTorrents(line)

#=====================================================
## Create Links
print "Executing Links"
for i in range(len(ary_tracker)):
 os.system("curl -u " + twitter_username + ":" + twitter_password + " -d status=\"" + ary_torrent[i] + "\" http://twitter.com/statuses/update.xml")
 print "Creating Link for: " + ary_torrent[i];
 if os.path.exists(link_directory + ary_tracker[i]) == 1:
  os.system("ln -s \"" + torrent_completed_dir + ary_directory[i] + "\" \"" + link_directory + ary_tracker[i] + "/" + ary_directory[i] + "\"")
 else:
  os.system("mkdir " + link_directory + ary_tracker[i])
  os.system("ln -s \"" + torrent_completed_dir + ary_directory[i] + "\" \"" + link_directory + ary_tracker[i] + "/" + ary_directory[i] + "\"")
 os.system("mv \"" + torrentfilesdirectory + ary_torrent[i] + "\" " + torrent_move_to_dir);

#=====================================================
## Display Error Torrents
if len(ary_errors) > 0:
 print "Errors Found:";
 for i in range(len(ary_errors)):
  print ary_errors[i];

403 Errors in Dreamweaver when trying to connect to a mysql database

June 21st, 2010

Afternoon all,
I’ve just spent the last 3 or so hours trying to solve a particulary annoying issue in Dreamweaver CS4, I wanted to connect to the mysql server using dreamweaver so I can create some code with a little more pollish than my current “nano” work. However each time i tried to fix this I got 403 error from the server. I did some minor work on the permissions (ie 755 chmod access) but nothing worked and then tried this and hey-presto it worked.

chown www-data\: _mmServerScripts/ _mmServerScripts/*
chgrp www-data _mmServerScripts/ _mmServerScripts/*

Obviously the above is valid for my setup and may require some modification for yours but it’s a nice easy fix.