コード例 #1
0
ファイル: user.py プロジェクト: Naveengnn/one
def sign_in():
  is_old = input('Do you already have a MediaFire account? [y/n] ')
  if (is_old[0].lower() == 'y'):
    email = input('What is your email: ').lower()
    password = getpass.getpass('What is your password: '******'w')
      ofstream.write(email + '\n') 
      ofstream.write(password)
      ofstream.close()
      client = existance[1]
      if (not check_one_existance(client)):
        try:
          client.create_folder('mf:/one_storage/')     
        except requests.exceptions.RequestException:
          logger.die('Network error, please check network status and try again')
      logger.end('You are signed in!')
    else:
      logger.die('Either your credentials are incorrect or your account does not exist.\nPlease try again or see MediaFire.com')
  elif (is_old[0].lower() == 'n'):
      logger.end('Please go to MediaFire.com and create an account.') 
  else:
    logger.log('Please answer with a a "n" or "y"')
    sign_in()
コード例 #2
0
ファイル: share.py プロジェクト: Naveengnn/one
def share(filename):
    exist = get_existance(filename)
    if (exist[1]):
        f = exist[1]
        mail(f['links']['normal_download'])
        logger.end(f['links']['normal_download'])
    else:
        logger.die('File "' + filename + '" does not exist')
コード例 #3
0
ファイル: share.py プロジェクト: cdpetty/one
def share(filename):
  exist = get_existance(filename)
  if (exist[1]):
    f = exist[1]
    mail(f['links']['normal_download'])
    logger.end(f['links']['normal_download'])
  else:
    logger.die('File "' + filename + '" does not exist')
コード例 #4
0
ファイル: one.py プロジェクト: cdpetty/one
def main():
  parser = build_arg_parser()

  args = parser.parse_args()
  if (args.sub_command == 'push'):
    if (len(args.files) == 0):
      logger.die('Must include at least one file')
    else:
      for f in args.files:
        upload.upload(f, args.MediaFire_Path) 
  elif (args.sub_command == 'pull'):
    if (len(args.files) == 0):
      logger.die('Must include at least one file')
    else:
      for f in args.files:
        download.download(f)
  elif (args.sub_command == 'del'):
    if (len(args.files) == 0):
      logger.die('Must include at least one file')
    else:
      for f in args.files:
          delete.delete(f)
  elif (args.sub_command == 'init'):
    if (user.is_user_signed_in()):
      logger.end('User is already initialized')
    else:
      user.get_auth()
  elif (args.sub_command == 'list'):
    if (len(args.files) == 0):
      lister.list_files('')
    else:
      for f in args.files:
        lister.list_files(f)
  elif (args.sub_command == 'diff'):
    if (len(args.files) == 0):
      logger.die('Must include at least one file')
    else:
        for f in args.files:
          diff.diff(f, args.MediaFire_Path)
        
  elif (args.sub_command == 'out'):
    user.log_out()
  elif (args.sub_command == 'change'):
    user.change_user()
  elif (args.sub_command == 'share'):
    if (len(args.files) == 0):
      logger.die('Must include at least on file')
    else:
      for f in args.files:
        share.share(f)
コード例 #5
0
def main():
    parser = build_arg_parser()

    args = parser.parse_args()
    if (args.sub_command == 'push'):
        if (len(args.files) == 0):
            logger.die('Must include at least one file')
        else:
            for f in args.files:
                upload.upload(f, args.MediaFire_Path)
    elif (args.sub_command == 'pull'):
        if (len(args.files) == 0):
            logger.die('Must include at least one file')
        else:
            for f in args.files:
                download.download(f)
    elif (args.sub_command == 'del'):
        if (len(args.files) == 0):
            logger.die('Must include at least one file')
        else:
            for f in args.files:
                delete.delete(f)
    elif (args.sub_command == 'init'):
        if (user.is_user_signed_in()):
            logger.end('User is already initialized')
        else:
            user.get_auth()
    elif (args.sub_command == 'list'):
        if (len(args.files) == 0):
            lister.list_files('')
        else:
            for f in args.files:
                lister.list_files(f)
    elif (args.sub_command == 'diff'):
        if (len(args.files) == 0):
            logger.die('Must include at least one file')
        else:
            for f in args.files:
                diff.diff(f, args.MediaFire_Path)

    elif (args.sub_command == 'out'):
        user.log_out()
    elif (args.sub_command == 'change'):
        user.change_user()
    elif (args.sub_command == 'share'):
        if (len(args.files) == 0):
            logger.die('Must include at least on file')
        else:
            for f in args.files:
                share.share(f)
コード例 #6
0
ファイル: list.py プロジェクト: cdpetty/one
def list_files(path):
  if (user.is_user_signed_in()):
    sanitized_path = sanitize_path(path)
    contents = get_files(sanitized_path)
    if (len(contents) == 0):
      logger.end('No Files Stored')
    else:
      logger.log('Files contained on MediaFire/One:')
      logger.log('   Type       Privacy    Revision   Size/File_Count    Filename')
      for f in contents:
        if (type(f) == File):
          logger.log(compose_list_string('File', f['privacy'], f['revision'], f['size'], f['filename']))
        elif (type(f) == Folder):
          logger.log(compose_list_string('Folder', f['privacy'], f['revision'], f['file_count'], f['name']))
  else:
    user.get_auth()
コード例 #7
0
ファイル: diff.py プロジェクト: cdpetty/one
def figure_time_scale(media_hash, old_hash, new_hash, filename):
  if (old_hash == media_hash and new_hash != old_hash and new_hash != media_hash):
    logger.end('One: The local file, "' + filename + '", is ahead of the remote.')
  elif(old_hash == media_hash == new_hash):
    logger.end('One: All files are properly synced.')
  elif(old_hash == new_hash and media_hash != old_hash and media_hash != new_hash):
    logger.end('One: The remote file, "' + filename + '", is ahead of the local file.')
  elif(old_hash != new_hash != media_hash):
    logger.end('One: The remote and head are out of sync.')
コード例 #8
0
ファイル: diff.py プロジェクト: Naveengnn/one
def figure_time_scale(media_hash, old_hash, new_hash, filename):
    if (old_hash == media_hash and new_hash != old_hash
            and new_hash != media_hash):
        logger.end('One: The local file, "' + filename +
                   '", is ahead of the remote.')
    elif (old_hash == media_hash == new_hash):
        logger.end('One: All files are properly synced.')
    elif (old_hash == new_hash and media_hash != old_hash
          and media_hash != new_hash):
        logger.end('One: The remote file, "' + filename +
                   '", is ahead of the local file.')
    elif (old_hash != new_hash != media_hash):
        logger.end('One: The remote and head are out of sync.')
コード例 #9
0
def list_files(path):
    if (user.is_user_signed_in()):
        sanitized_path = sanitize_path(path)
        contents = get_files(sanitized_path)
        if (len(contents) == 0):
            logger.end('No Files Stored')
        else:
            logger.log('Files contained on MediaFire/One:')
            logger.log(
                '   Type       Privacy    Revision   Size/File_Count    Filename'
            )
            for f in contents:
                if (type(f) == File):
                    logger.log(
                        compose_list_string('File', f['privacy'],
                                            f['revision'], f['size'],
                                            f['filename']))
                elif (type(f) == Folder):
                    logger.log(
                        compose_list_string('Folder', f['privacy'],
                                            f['revision'], f['file_count'],
                                            f['name']))
    else:
        user.get_auth()
コード例 #10
0
                    c.send(fl.encode())
                    sleep(1)
                    with open(f'{cwd}/uploads/{fl}', 'rb') as fl:
                        data = fl.read()
                        c.send(str(len(data)).encode())
                        sleep(1)
                        c.send(data)
                elif req == 'CLOSE':
                    os.chdir(cwd)
                    os.system(f'kill -9 {spid}')
                    sleep(1)
                    os.execv(f'/files/Vignesh/Server/Server.py', sys.argv)
                    #os.system('./Server.py')

        except OSError:
            os.chdir(cwd)
            os.system(f'kill -9 {spid}')
            os.execv(f'/files/Vignesh/Server/Server.py', sys.argv)
            #os.system('./Server.py')

        except:
            os.chdir(cwd)
            print('ERROR: 404')
            os.system(f'kill -9 {spid}')
            sleep(1)
            os.execv(f'/files/Vignesh/Server/Server.py', sys.argv)
            #os.system('./Server.py')

lg.end()
lg.endlogfile()
コード例 #11
0
ファイル: user.py プロジェクト: Naveengnn/one
def log_out():
  os.unlink(os.path.expanduser('~/.one'))
  logger.end('You have been logged out.')
コード例 #12
0
ファイル: twitterSiphon.py プロジェクト: anudeep3998/cse535
 def on_data(self, data) :
     global count
     global interesting_count
     global int_german
     global int_russian
     global tw_writer
     global _TOTAL_LIMIT
     global _INTERESTING_LIMIT
     global _STRICT_INTERESTING_LIMIT_LOWER
     global init_by
     
     tweet = customTweet(data)
     
     
     if tweet.is_lang_interesting() and tweet.is_term_interesting() and tweet.is_original():
         if tweet.is_lang_german():
             int_german = int_german + 1
         if tweet.is_lang_russian():
             int_russian = int_russian + 1
             
         interesting_count+=1
         print("Got a new tweet :: Total # : "+ str(int_german)+"-"+str(int_russian)+"|"+str(interesting_count-int_german-int_russian)+"/"+str(count))
         
         if tweet.is_lang_german() :
             tw_writer.dump_tweet(data,'de')
         elif tweet.is_lang_russian() :
             tw_writer.dump_tweet(data,'ru')
         elif tweet.is_lang_english() :
             tw_writer.dump_tweet(data,'en')
         
         
         if (interesting_count <= _INTERESTING_LIMIT and count <= _TOTAL_LIMIT) or interesting_count <= _STRICT_INTERESTING_LIMIT_LOWER :
             '''try:
                 #req = requests.post(update_url[count%2]+update_url_args[0 if count%25==0 else 1], data = tweet.encode_to_json(), headers=headers)
                 pass
             except Exception:
                     logger.log("Solr offline. Attempting wake")
                     p = subprocess.Popen(str("/home/anudeep3998/cse535/solr/solr-5.3.0/bin/solr start -e cloud -noprompt"), stdout=subprocess.PIPE, shell=True)
                     (output, err) = p.communicate()
                     if err :
                         logger.log("Couldn't wake solr. Terminating.")
                         sys.exit(0)
                     else :
                         logger.log("solr wake successful. Continuing..")
             '''
             pass
             #print(req.text)
             #print("Pushing to SOLR : return# "+str(req.status_code))
         else:
             '''
                 commit both cores. One duplicate tweet will be added to one of the core, but shouldn't matter over the other count
             '''
             #req = requests.post(update_url[1]+update_url_args[0], data = tweet.encode_to_json(), headers=headers)
             #req = requests.post(update_url[0]+update_url_args[0], data = tweet.encode_to_json(), headers=headers)
             msg = "["+init_by+"] Successfully completed dump :: Total # : G["+ str(int_german)+"]-R["+str(int_russian)+"] | E["+str(interesting_count-int_german-int_russian)+"] / T["+str(count)+"]"
             print(msg)
             logger.end(msg)
             sys.exit(0)
     elif not tweet.is_original():
         print("retweet/quoted tweet. Scanned["+str(count)+"]")
     else:
         print("Unkown or uninteresting language/term, skipping. Scanned["+str(count)+"]")
     #print("Got a new tweet :: "+parsed_text['text'].encode('ascii', 'ignore').decode('ascii')+"\nTotal # : "+ str(count))
     count = count + 1
     
     #terminate after limit
     if count > _TOTAL_LIMIT and interesting_count > _STRICT_INTERESTING_LIMIT_LOWER :
         msg = "["+init_by+"] Successfully completed dump :: Total # : G["+ str(int_german)+"]-R["+str(int_russian)+"] | E["+str(interesting_count-int_german-int_russian)+"] / T["+str(count)+"]"
         logger.end(msg)
         print(msg)
         sys.exit(0)
     
     return True
コード例 #13
0
ファイル: twitterSiphon.py プロジェクト: anudeep3998/cse535
    def on_error(self, status) :
        print(status)
        

auth = OAuthHandler(ckey,csecret)
auth.set_access_token(atoken,asecret)

try:
    twitterStream = Stream(auth,twitterListener())
    msg = " initiated run"
    
    try:
        if sys.argv[1] == "cron":
            msg = "cron" + msg
            init_by = 'cron'
        else:
            msg = "user" + msg
            init_by = 'user'
    except Exception:
         msg = "user" + msg
         init_by = 'user'
    print(msg)
    logger.start(msg)
    twitterStream.filter(track=term_set)
    
except KeyboardInterrupt:
    print("["+init_by+"] Caught KeyboardInterrupt :: Total # : G["+ str(int_german)+"]-R["+str(int_russian)+"] | E["+str(interesting_count-1-int_german-int_russian)+"] / T["+str(count))+"]"
    logger.end("["+init_by+"] Caught KeyboardInterrupt :: Total # : G["+ str(int_german)+"]-R["+str(int_russian)+"] | E["+str(interesting_count-1-int_german-int_russian)+"] / T["+str(count))+"]"
    sys.exit(0)