This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __author__ = 'giasuddin' | |
| from cassandra.cqlengine.connection import setup | |
| from cassandra.cluster import Cluster | |
| from cassandra.auth import PlainTextAuthProvider | |
| from cassandra.query import dict_factory | |
| from cassandra.cqlengine import connection | |
| from cassandra.policies import RoundRobinPolicy | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def connect21(keyspace="test_keyspace"): | |
| """ | |
| Cassandra connection by using python driver | |
| connect to cassandra 2.1 with protocol version 3 | |
| :param keyspace: | |
| :return: | |
| """ | |
| auth_provider = PlainTextAuthProvider(username="cassandra", password="cassandra") | |
| cluster = Cluster(["127.0.0.1"], auth_provider=auth_provider, protocol_version=4) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __author__ = 'giasuddin' | |
| from cassandra.cqlengine import management | |
| from cassandra.cqlengine.columns import * | |
| from cassandra.cqlengine.models import Model | |
| from datetime import datetime | |
| import uuid | |
| import cassandra | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| import glob, os | |
| def file_rename(dir, pattern, titlePattern): | |
| for pathAndFilename in glob.iglob(os.path.join(dir, pattern)): | |
| title, ext = os.path.splitext(os.path.basename(pathAndFilename)) | |
| replace_file = re.sub("[^a-zA-Z0-9_]+", "_", title) | |
| new_filename = (replace_file + ext ).lower() | |
| os.rename(pathAndFilename, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __author__ = 'giasuddin' | |
| from pyramid.view import view_config | |
| import os | |
| @view_config(request_method='POST', renderer='json') | |
| def post(self): | |
| file_type = self.request.matchdict['file_type'] | |
| node_type = self.request.matchdict['node_type'] | |
| sanitize_file = False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __author__ = 'giasuddin' | |
| from pyramid.response import Response, FileResponse | |
| import os | |
| from pyramid.view import view_config | |
| @view_config(route_name='download', renderer='json') | |
| def download_view(request): | |
| if request.params.get('filename', ''): | |
| filename = request.params['filename'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __author__ = 'giasuddin' | |
| def is_ascii(s): | |
| return all(ord(c) < 128 for c in s) | |
| if __name__ == '__main__': | |
| test=is_ascii('রিকোয়ারমেন্') | |
| print(test) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __author__ = 'giasuddin' | |
| def pager(total_row=None, item_per_page=None): | |
| """ | |
| We are using this function for pagination database total row. | |
| Then using offset for query | |
| """ | |
| pages = {} | |
| total_page = total_row/item_per_page |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __author__ = 'giasuddin' | |
| import requests | |
| import os | |
| f_url = "http://files.test.org.bd/crop/250/300/media/image/publication/wallpaper_poster_20180307.jpg" | |
| STORAGE_DESTINATION = "/home/giasuddin/Pictures/" | |
| def file_download(file_url): |
OlderNewer