def setUp(self):
        """
        Create a default connection
        """
        self.conn = Connection("TEST_ACCESS_KEY", "TEST_SECRET_KEY", tls=True)

        self.dummy_data = StringIO('DUMMY_DATA')
def upload_to_s3(result, similarity):
    aws_access_key = os.getenv('AWS_ACCESS_KEY')
    aws_access_secret = os.getenv('AWS_ACCESS_SECRET')
    if aws_access_key is None or aws_access_secret is None:
        return
    remote = os.popen('git config --get remote.origin.url').read().strip()
    match = re.match('.*/([a-zA-Z0-9_-]+)/spoqa-pycon-2015-codegolf.git', remote)
    if match is None:
        participant = 'unknown'
    else:
        participant = match.group(1)
    now = datetime.datetime.now().strftime('%y%M%d-%H%M%S')
    name = '%s-%s-%d.txt' % (participant, now, similarity * 100)
    conn = Connection(aws_access_key, aws_access_secret,
                      default_bucket='entries',
                      endpoint='pycon-2015-codegolf.s3.amazonaws.com')
    conn.upload(name, StringIO(result))
Beispiel #3
0
def upload_to_s3(result, similarity):
    aws_access_key = os.getenv('AWS_ACCESS_KEY')
    aws_access_secret = os.getenv('AWS_ACCESS_SECRET')
    if aws_access_key is None or aws_access_secret is None:
        return
    remote = os.popen('git config --get remote.origin.url').read().strip()
    match = re.match('.*/([a-zA-Z0-9_-]+)/spoqa-pycon-2015-codegolf.git', remote)
    if match is None:
        participant = 'unknown'
    else:
        participant = match.group(1)
    now = datetime.datetime.now().strftime('%y%M%d-%H%M%S')
    name = '%s-%s-%d.txt' % (participant, now, similarity * 100)
    conn = Connection(aws_access_key, aws_access_secret,
                      default_bucket='entries',
                      endpoint='pycon-2015-codegolf.s3.amazonaws.com')
    conn.upload(name, StringIO(result))
 def setUp(self):
     """
     Create a default connection
     """
     self.conn = Connection("TEST_ACCESS_KEY", "TEST_SECRET_KEY", tls=True)
     # Some test values we use among the unit tests...
     self.test_key = 'test_key'
     self.test_bucket = 'bucket'
     self.uploadId = ("VXBsb2FkIElEIGZvciA2aWWpbmcncyBteS1tb3ZpZS5t"
                      "MnRzIHVwbG9hZA")
Beispiel #5
0
def add(file_path, category, dry_run):
    click.secho("Uploading %s :" % file_path, fg="green")

    bucket_name = BUCKETS[category]
    abs_path = path.abspath(file_path)
    filename = format_filename(path.basename(abs_path))
    shasum = sha1sum(abs_path)
    dest_path = "pub/%s/%s" % (shasum, filename)
    public_url = "https://%s.paridans.com/%s" % (category, dest_path)

    click.echo("Ready to upload into '%s' with path '%s'" %
               (bucket_name, dest_path))

    if not dry_run:
        s3_conn = Connection(environ.get("S3_ACCESS_KEY"),
                             environ.get("S3_SECRET_KEY"),
                             tls=True,
                             endpoint='s3-eu-west-1.amazonaws.com')
        with open(abs_path, "rb") as f:
            s3_conn.upload(dest_path, f, bucket_name)
        click.echo("Uploaded successfully to:")
        click.secho(public_url, fg="green")
    else:
        click.secho("Dry run", fg="red")
Beispiel #6
0
from s3dict import S3Dict
from tinys3 import Connection

c = Connection(os.environ['S3_ACCESS_KEY'],os.environ['S3_SECRET_KEY'])

def test_
 def setUp(self):
     self.conn = Connection("TEST_ACCESS_KEY", "TEST_SECRET_KEY", tls=True)
     self.r = ListRequest(self.conn, 'prefix', 'bucket')
     self.adapter = flexmock()
     flexmock(self.r).should_receive('adapter').and_return(self.adapter)
Beispiel #8
0
 def setUp(self):
     """
     Create a default connection
     """
     self.conn = Connection("TEST_ACCESS_KEY", "TEST_SECRET_KEY", tls=True)
Beispiel #9
0
`libcheckin <book name> [@<username>]`
You can see a list of all borrowed books like this. This will also happen once a week automatically
`library`

Anything else and I'll show you this message to help you out!

If you have any facts you want to add, comments, complaints, or bug reports, message Jack Reichelt.
"""

TOKEN = os.environ.get(
    'TOKEN', None)  # found at https://api.slack.com/web#authentication
S3_ACCESS_KEY = os.environ.get('S3_ACCESS_KEY', None)
S3_SECRET_KEY = os.environ.get('S3_SECRET_KEY', None)

conn = Connection(S3_ACCESS_KEY,
                  S3_SECRET_KEY,
                  endpoint='s3-ap-southeast-2.amazonaws.com')

saved_subs = conn.get('borrowers.txt', 'iit-library')

f = open('borrowers.txt', 'wb')
f.write(saved_subs.content)
f.close()

lib = Library()

sc = SlackClient(TOKEN)
if sc.rtm_connect() == True:
    print('Connected.')

    sc.api_call("im.list")
    cf.write_subscribers()
    conn.upload('subscribers.txt', open('subscribers.txt', 'rb'),
                'better-cat-facts')


#     sys.exit(0)
#
# signal.signal(signal.SIGTERM, sigterm_handler)

TOKEN = os.environ.get(
    'TOKEN', None)  # found at https://api.slack.com/web#authentication
S3_ACCESS_KEY = os.environ.get('S3_ACCESS_KEY', None)
S3_SECRET_KEY = os.environ.get('S3_SECRET_KEY', None)

conn = Connection(S3_ACCESS_KEY,
                  S3_SECRET_KEY,
                  endpoint='s3-ap-southeast-2.amazonaws.com')

saved_subs = conn.get('subscribers.txt', 'better-cat-facts')

f = open('subscribers.txt', 'wb')
f.write(saved_subs.content)
f.close()

cf = CatFacts()

sc = SlackClient(TOKEN)
if sc.rtm_connect() == True:
    print('Connected.')

    sc.api_call("im.list")
"""

@atexit.register
def save_subs():
  print('Writing subscribers.')
  cf.write_subscribers()
  conn.upload('subscribers.txt', open('subscribers.txt', 'rb'), 'better-cat-facts')
#     sys.exit(0)
#
# signal.signal(signal.SIGTERM, sigterm_handler)

TOKEN = os.environ.get('TOKEN', None) # found at https://api.slack.com/web#authentication
S3_ACCESS_KEY = os.environ.get('S3_ACCESS_KEY', None)
S3_SECRET_KEY = os.environ.get('S3_SECRET_KEY', None)

conn = Connection(S3_ACCESS_KEY, S3_SECRET_KEY, endpoint='s3-ap-southeast-2.amazonaws.com')

saved_subs = conn.get('subscribers.txt', 'better-cat-facts')

f = open('subscribers.txt', 'wb')
f.write(saved_subs.content)
f.close()

cf = CatFacts()

sc = SlackClient(TOKEN)
if sc.rtm_connect() == True:
  print('Connected.')

  sc.api_call("im.list")