网易263企业邮箱登陆网页网页版电脑最近登不进去

自动化运维工具Fabric - 密码管理(env.password and ssh key)_服务器应用_Linux公社-Linux系统门户网站
你好,游客
自动化运维工具Fabric - 密码管理(env.password and ssh key)
来源:Linux社区&
作者:Linux
在使用 Fabric 的过程中,如果大批量服务器处理的话,我们就需要针对配置主机的密码,每台主机的密码相同还好,不同的话,就需要针对不同的主机做配置了,以下有两种配置方式
注:本文主要参考官方文档
Fabric 在某些场合下通过保持在内存中以及双重缓存来帮助你记录登录密码以及 sudo 密码。当多个系统的密码一样的时候,这可以避免让你重复乏味的输入密码。或者是一个远程系统的 sudo 配置文件没有缓存它自己的密码时候。
第一层是一个默认简单的或是备用的密码缓存。
(它也可以通过命令行参数
来设定)。这个 env 变量存储单个密码,它会咋当前的
没有指定的主机缓存条目的事件的时候尝试。
(复数,表示多个密码),作为每一个主机用户的缓存,为唯一的 user/host/port 组合存储了最近输入的密码。由于这个缓存,连接具有相同 session 的不同用户和主机,仅仅只要求单个的密码。
依赖于你的配置文件以及你 session 连接的主机的数目,你可能会发现设置这些 env 是非常有用的。尽管如此, Fabric 会在必要的时候自动填充他们,不需要你多余的配置。
特别说明,每次对用户提出的密码提示,这值都会被用于更新这默认的密码缓存以及 env.host_string 当前值的缓存值。
没代码说的球,上代码。NO CODE NO BB
所有主机密码一样的代码,下面代码的几台主机是用户名和密码一样的,主要做的事情是批量注释,批量停止应用,以及批量关机
from fabric.api import env
from fabric.api import cd
from fabric.api import run
from fabric.api import local
from fabric.api import get
from fabric.api import put
env.user = 'username'
env.password = 'passwd'
env.hosts = ['192.168.1.1', '192.168.1.2', '192.168.1.3', '192.168.1.4']
def get_version():
local('cat /etc/issue')
run('cat /etc/issue')
def get_host_name():
run('hostname')
def kill_apps_stockd():
run('killall stockd')
def comment_crontabl():
put ('/home/apps/ykq/crontab.txt','crontab.txt')
run('crontab crontab.txt')
def offline_stockd():
kill_apps_stockd()
comment_crontabl()
def shutdown_stockd_server():
run('sudo poweroff')
所有主机的用户名一样,但密码不一样这里感谢@Kollin 的提示,修正下错误,并且以他的示例程序为例。不过感觉这个Fabric的这方面这样做的原因应该是&基于不同的用户名和不同的密码考虑的&没有考虑过相同用户名,不同密码的情况。如果要这样做,个人感觉可以修改源码,然后支持env.user 和 env.passwords拼接的方式。不然每个值都要输入 user@ 这样要多写很多代码
错误的示例程序。
env.user = 'username'
env.passwords = {'192.168.1.1':'passwd1','192.168.1.2':'passwd2','192.168.1.3':'passwd3'}
env.hosts = ['192.168.1.1', '192.168.1.2', '192.168.1.3']
正确的 @Kollin的示例程序
from fabric.api import *
env.hosts = [
'user@192.168.1.1',
'user@192.168.1.2',
env.passwords = {
'user@192.168.1.1:22': 'password1',
'user@192.168.1.2:22': 'password2',
def echo():
run('echo "hello,world"')
注:后续会专门写一篇关于 Fabric 中角色的文章
官方文档中建议,为了安全起见,最好是使用 SSH KEY 的方式来批量执行主机,操作方式如下:
登录服务器,生成 SSH Key
$ ssh-keygen -t rsa -b 4096
键入以上命令后,会出现一连串的提示,忽略它,一直按回车键即可。执行完成后,将在用户的 ~/.ssh/ 目录生成以下两个文件:
~/.ssh/id_rsa
~/.ssh/id_rsa.pub 公钥
把生成的公钥文件 ~/.ssh/id_rsa.pub里面的数据添加进远程服务器的 authorized_keys file 文件中
注:如果远程服务器没有 .ssh 文件夹,需要创建
scp ~/.ssh/id_rsa.pub user@host:~/.ssh/
cat ~/.ssh/id_rsa.pub && authorized_keys
然后准备我们的用我们的 SSH Key 代替我们的密码:
from fabric.api import *
from fabric.colors import *
from fabric.context_managers import *
env.hosts=['168.192.1.10','168.192.1.12']
env.key_filename = "~/.ssh/id_rsa"
def ls_path():
print(green("I'm local
/home/apps/"))
with cd('/home/apps'):
run('ls -l')
def put_path():
print(green("I'm put local's test file to 10 and 12"))
put('/home/apps/test','/home/apps/')
print(yellow("I'm 10 or 12 /home/apps/"))
with cd('/home/apps'):
run('ls -l')
def deploy():
execute(ls_path)
execute(put_path)
相关资讯 & & &
& (10/22/:23)
& (02/02/:30)
& (10/15/:19)
& (06/15/:39)
& (11/01/:51)
   同意评论声明
   发表
尊重网上道德,遵守中华人民共和国的各项有关法律法规
承担一切因您的行为而直接或间接导致的民事或刑事法律责任
本站管理人员有权保留或删除其管辖留言中的任意内容
本站有权在网站内转载或引用您的评论
参与本评论即表明您已经阅读并接受上述条款6764人阅读
JavaScript(34)
Fabric 的学习
&&&&&& Fabric provides a missing object model forcanvas, as well as an SVG parser, layer of interactivity, and a whole suite ofother indispensable tools.&
& & 在canvas的底层基础上提供了 object&model
& & 提供 canvas的 rendering和state管理
基本类型: & &
&&&&fabric.Circle
& & fabric.Ellipse
& & fabric.Line
& & fabric.Polygon
& & fabric.Polyline
& & fabric.Rect
& & fabric.Triangle
操作对象:
& & 属性 get('width')和 set({ }):&positioning —&left,⊤ dimension —&width,&height; rendering —&fill,&opacity,&stroke,strokeWidth;
scaling and rotation —&scaleX,&scaleY,∠ and even those related to flipping —&flipX,&flipY.
&&&&&& 状态变化时的动作:通过event来实现
&&&&&& 动画
层次关系:
& & fabric.Object: 代表二维形状,具有属性&left/top and width/height properties, as well as a slew of other graphiccharacteristics. Those properties that we saw on objects — fill, stroke, angle, opacity, flip*, etc。 可以在fabric.Object.prototype 定义函数,在fabric.Object的子类上共享
& & fabric.Circle 有 radius属性
& & fabric.Image 有 setElement和getElement
& & 是&canvas&的包装类,管理所有的fabric.Object
& & 有方法: add &getObjects& item &remove.
& & 配置:背景色或背景图片,剪切,是否交互等。
Interactive:
&& &选择、拖动、旋转、放大、group together的操作
& & 步骤:
&&&&& & 初始化 canvas,加载 object model&&&&
&&&&& & 使用 selection 和selectable属性&canvas.selection =// disable group selection &&rect.set('selectable', false); // makeobject unselectable
&&&&创建一不含交互的canvas(轻量级)
&&&&&&& var staticCanvas = newfabric.StaticCanvas('c');
&&&&&&&&staticCanvas.add(。。。)
& & 有&img& html标签时:使用 fabric.Image&
& & 有 url 时: fabric.Image.fromUrl, 回调函数中的参数就是fabric.Image
Path和PathGroup
& & 制作任意向量图
& & path 包括一系列的命令,如&“move”, “line”, “curve”, or “arc”, 类似于 svg 的&path& ,可使用 fabric.Path手动创建,步骤:&
&&&&& & varpath=new fabric.Path
&&&&& &path.set
& &&也可使用 fabric内置的 SVG Parser创建(真创建复杂图形,这种方法比较多),步骤:
&&&&&&&使用 fabric.loadSVGFromString &loadSVGFromURL加载整个SVG
&&&&& & 使用 SVG Parser得到 path对象
& & PathGroup是Path的集合,集成于fabric.Object,所以可以add到cavas中
Animation&&&
& & 使用 animate 函数,包括三个参数:属性、值(支持目标值,如300, 相对值,如'+=100')、回调函数(支持 duration, from,onComplete, easing change等,一般监听change事件。 )
& & onChange:&canvas.renderAll.bind(canvas) 在每帧变化时重新渲染,可看到动画效果
& & easing 代表变化函数,可取的值是fabric.util.ease包下,有easeOutBounce & easeInCubic &easeOutCubiceaseInElastic easeOutElastic easeInBounce 和easeOutExpo
& & 图片滤镜效果,预支持的有 remove whitebackground & grayscale filter &invert or brigtness one , gradienttransparentcy, sepia, noise
& & 使用fabric.Image.filters.push &,再调用&img.applyFilters(canvas.renderAll.bind(canvas));
& & 支持的&remove&filter (via&pop,&splice, or&shift),&add&filter (via&push,&splice,&unshift), or even combine multiple filters.
&& & 可自定义filter: 略,参考filter中相应章节
& & 支持多种color的定义,如rgb rgba hex等
& &&newfabric.Color('#123123');
&&&&newfabric.Color('rgb(100,0,100)');
&&&&使用Object 中的setGradientFil函数,如
&&&&circle.setGradientFill({
& y2:circle.height,
&colorStops: {
&&& 0:'#000',
&&& 1:'#fff'
&&&&其中 x1,y1定义开始点,x2,y2定义结束点,colorStops 可以有多个,从 0 to 1 (e.g. 0, 0.1, 0.3,0.5, 0.75, 1),如彩虹七色
Text(艺术字)
Multiline support. Native text methods unfortunately simply ignore new lines.Text alignment. Left, center, right. Useful when working with multiline text.Text background. Background also respects text alignment. Text decoration. Underline, overline, strike-through. Line height. Useful when working with multiline text
&&如:var text = newfabric.Text('hello world', { left: 100, top: 100 });
&&&&其中第二个参数可选,可以为left, top, fill, opacity,fontFamily ,fontSize& fontWeight textShadow, fontStyle& strokeStyle&strokeWidth&textBackgroundColor&lineHeight&& textAlign.
提供从低端的mouse到高端的object 事件,如:
&&mouse-level:
&&&&&&&&&&& &mouse:down&,&mouse:move&, and &mouse:up&.
&& genericones:
&&&&&&&&&&& &after:render&.
&&&&selection-related:
&&&&&&&&&&&&&& &before:selection:cleared&,&selection:created&, &selection:cleared&.
&&&&object ones:
&&&&&&&&&&&&&& &object:modified&,&object:selected&, &object:moving&, &object:scaling&,&object:rotating&, and &object:added&..
& 使用 on 监听事件,off 移除监听器
&&&&Note that eventslike &object:moving& (or &object:scaling&) are fired continuouslyevery time an object is moved (or scaled) even by one pixel. On the other hand,events like &object:modified& or &selection:created& arefired only at the end
of the action (object modification or selectioncreation).
&&&&也可以直接给 model object 添加事件&&canvas.on('mouse:down', function(options){console.log(options.e.clientX, options.e.clientY); });&&& 其中options有两个属性,一个e 代表事件,target 代表事件发出的对象
&&&&对多个物体统一移动和修改(scale& rotate等)
&&&&//创建一个 labeledeclipse&&&&
var group = new fabric.Group([ text,circle ], {
& left:150,
& top:100,
&angle: -10
canvas.add(group);
//修改group中的个体
group.item(0).set({
& text:'trololo',
& fill:'white'
group.item(1).setFill('red');
& &group中item默认布局在group中央,通过给每个item设置left和top属性可修改&
& & 其他函数: getObjects() 获得group中所有对象, item 取得单个对象 &等
& & 创建已经在 canvas中加载的对象的group
&&&&&&&var group = new fabric.Group([
&&&&canvas.item(0).clone(),
&canvas.item(1).clone()
&&&&// remove all objects and re-render
canvas.clear().renderAll();
// add group onto canvas
canvas.add(group);
Serialization
&&&&用于传递数据到其他客户端和服务器。以text方式
toObject,toJSON
&&&&其中 toObject 转化为object格式,toJSON转换为json 字符串
&&&&实例:
&&&&//将对象转为字符串
&&&&var canvas = new fabric.Canvas('c');
&&&&&&&JSON.stringify(canvas); // '{&objects&:[],&background&:&rgba(0,0, 0, 0)&}'
&&&&对于自定义类,只要定义 toObject函数,当使用 canvas.toObject()时就可以递归调用,类似于java的toString。
&&&&canvas的另一种文本格式,好处是生成的文本可以被外部的SVG程序解析,
Deserialization,SVG parser
&&fabric.Canvas#loadFromJSON 对应 上面的canvas.toJSON();
&fabric.Canvas#loadFromDatalessJSON用于加载复杂图形,如带path的,对应 canvas.toDatalessJON() ,需要对图形设置sourcePath,如:
&&&&canvas.item(0).sourcePath ='/assets/dragon.svg';
console.log(JSON.stringify(canvas.toDatalessJSON()));
&&&&fabric.loadSVGFromURL和fabric.loadSVGFromString
&&&&fabric.loadSVGFromString('...',function(objects, options) {
& varobj = fabric.util.groupSVGElements(objects, options);
&canvas.add(obj).renderAll();
Subclassing
&&&&支持对象的子类化扩展,略
Free drawing
&&&&支持在canvas上任意画,步骤:
&&&&1.canvas.isDrawingMode(true)后将鼠标的移动认为是pen和brush。
&&&&2. 当mouse:up后,fabric发出 path:created事件,并创建fabric.Path实例
&&&&3. canvas.isDrawingMode(false)终止绘画
&&&&可设置canvas的 freeDrawingColor and freeDrawingLineWidth
Customization
&&&&设置canvas及其对象的参数
&&&&Lockingobjects:如obj.lockRotation= 可设置&lockMovementX&, &lockMovementY&, &lockRotation&,&lockScaling&
&&&&Changeborder corners: hasBorders&& hasControls& borderColor&cornerColor& cornerSize
&&&&Disablingselection: canvas.selection 对所有有效 ,obj.selectable对单个有效
&&&&customizingselection: 修改选中样式 &selectionColor&, &selectionBorderColor&,&selectionLikeWidth&, and
&selectionDashArray&
&&&&dashedstroke:边的stroke样式
&&&&clickablearea:
&&&&rotatingpoint
&&&&objecttransformation:uniScaleTransform
&&&&canvasbackground和overlay:backgroundColor, backgroundImagesetOverlayImage(最上层图像)
Fabric on Node.js
&&&&可以让js在服务器上运行,如发送数据,在服务器上生成图片。
& &&/fabric-intro-part-1/#objects
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:331465次
积分:6963
积分:6963
排名:第2564名
原创:379篇
转载:44篇
评论:18条Java Code Example io.fabric.sdk.android.Fabric
Java Code Examples for io.fabric.sdk.android.Fabric
The following are top voted examples for showing how to use
io.fabric.sdk.android.Fabric. These examples are extracted from open source projects.
You can vote up the examples you like and your votes will be used in our system to product
more good examples.
+ Save this class to your library
public void onCreate() {
super.onCreate();
// crashlytics
if (!BuildConfig.DEBUG) {
Fabric.with(this, new Crashlytics());
// picasso
Picasso.Builder builder = new Picasso.Builder(this);
builder.downloader(new OkHttpDownloader(this, Integer.MAX_VALUE));
Picasso picasso = builder.build();
Picasso.setSingletonInstance(picasso);
Iconify.with(new FontAwesomeModule());
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
Fabric.with(this, new Twitter(authConfig));
Fabric.with(this, new TweetComposer());
setContentView(R.layout.activity_splash_screen);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
new Handler().postDelayed(new Runnable() {
public void run() {
Intent accountPortalIntent = new Intent(SplashScreen.this, MainActivity.class);
startActivity(accountPortalIntent);
}, SPLASH_TIME_OUT);
PreferencesLayer.initialize(getSharedPreferences(&prefs&, Context.MODE_PRIVATE));
String id = PreferencesLayer.getInstance().getKey();
Util.phoneNumbers = PreferencesLayer.getInstance().getPhoneNumbers();
Util.emails = PreferencesLayer.getInstance().getEmails();
if (id.equals(&&)) {
new RegisterTask().execute();
public void onCreate() {
super.onCreate();
// Twitter should come before the graph because of logging
TwitterAuthConfig authConfig = new TwitterAuthConfig(BuildConfig.TWITTER_API_KEY, BuildConfig.TWITTER_API_SECRET);
Fabric.with(this, FabricKits.list(authConfig));
LoggerStarter.start();
PRNGFixes.apply();
objectGraph = ObjectGraph.create(Modules.list(this));
FacebookSdk.sdkInitialize(this);
public void configCrashAnalytics(Context appContext) {
DefaultPrefHelper_ prefHelper = DefaultPrefHelper_.getInstance_(appContext);
if (prefHelper.sendCrashReports()) {
Fabric.with(appContext, new Crashlytics());
public void onCreate() {
super.onCreate();
Fabric.with(this, new Crashlytics());
// The following line triggers the initialization of ACRA
//ACRA.init(this);
public void onCreate() {
if (Utils.isDebugBuild()) {
StrictModeUtils.detectAllVmPolicy();
super.onCreate();
Fabric.with(this, new Crashlytics());
mHandler = new Handler();
mMessageBus = new Bus();
//mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, MODE_PRIVATE);
//mPreferences.registerOnSharedPreferenceChangeListener(this);
initializeAsyncTask();
initAccountColor(this);
initUserColor(this);
final PackageManager pm = getPackageManager();
final ComponentName main = new ComponentName(this, MainActivity.class);
final ComponentName main2 = new ComponentName(this, MainHondaJOJOActivity.class);
final boolean mainDisabled = pm.getComponentEnabledSetting(main) != PONENT_ENABLED_STATE_ENABLED;
final boolean main2Disabled = pm.getComponentEnabledSetting(main2) != PONENT_ENABLED_STATE_ENABLED;
final boolean noEntry = mainDisabled && main2D
if (noEntry) {
pm.setComponentEnabledSetting(main, PONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
} else if (!mainDisabled) {
pm.setComponentEnabledSetting(main2, PONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
startRefreshServiceIfNeeded(this);
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
/*if (Constants.LOG_ENABLED)
Ion.getDefault(this).configure().setLogging(&IonLogs&, Log.DEBUG);*/
if(!PrefUtils.contains(this, &intro&)) {
Intent intent = new Intent(this, IntroActivity.class);
startActivity(intent);
setContentView(R.layout.activity_framelayout);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
if(Build.VERSION.SDK_INT & Build.VERSION_CODES.JELLY_BEAN_MR2) {
toolbar.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, getResources().getDimensionPixelSize(R.dimen.abc_action_bar_default_height_material) + PixelUtils.getStatusBarHeight(this)));
toolbar.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, getResources().getDimensionPixelSize(R.dimen.abc_action_bar_default_height_material)));
progressBar.setVisibility(View.GONE);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out);
fragmentTransaction.replace(R.id.frameLayout, new InstanceListFragment());
public void onCreate() {
super.onCreate();
long startDate = SystemClock.elapsedRealtime();
mContext =
ProfilingUtils.start(&App Startup&);
// Enable log recording
AppLog.enableRecording(true);
AppLog.i(T.UTILS, &WordPress.onCreate&);
if (!PackageUtils.isDebugBuild()) {
Fabric.with(this, new Crashlytics());
versionName = PackageUtils.getVersionName(this);
initWpDb();
enableHttpResponseCache(mContext);
// EventBus setup
EventBus.TAG = &WordPress-EVENT&;
EventBus.builder()
.logNoSubscriberMessages(false)
.sendNoSubscriberEvent(false)
.throwSubscriberException(true)
.installDefaultEventBus();
EventBus.getDefault().register(this);
RestClientUtils.setUserAgent(getUserAgent());
// Volley networking setup
setupVolleyQueue();
AppLockManager.getInstance().enableDefaultAppLockIfAvailable(this);
if (AppLockManager.getInstance().isAppLockFeatureEnabled()) {
AppLockManager.getInstance().getCurrentAppLock().setDisabledActivities(
new String[]{&org.wordpress.android.ui.ShareIntentReceiverActivity&});
HelpshiftHelper.init(this);
ApplicationLifecycleMonitor applicationLifecycleMonitor = new ApplicationLifecycleMonitor();
registerComponentCallbacks(applicationLifecycleMonitor);
registerActivityLifecycleCallbacks(applicationLifecycleMonitor);
initAnalytics(SystemClock.elapsedRealtime() - startDate);
public void onCreate() {
if (BuildConfig.USE_CRASHLYTICS) {
Fabric.with(this, new Crashlytics());
super.onCreate();
Example 10
public void onCreate() {
super.onCreate();
Parse.enableLocalDatastore(this);
Parse.initialize(this, Constants.getConstant(this, R.string.PARSE_APP_ID),
Constants.getConstant(this, R.string.PARSE_CLIENT_KEY));
Fabric.with(this, new Crashlytics());
Crashlytics.getInstance().setDebugMode(false);
Crashlytics., StarterApplication.class.getName(), &Starting Application - & + System.currentTimeMillis());
NewsCatFileUtil.getInstance(this);
UserPrefUtil.getInstance(this);
ParseConfig.getInBackground(new ConfigCallback() {
public void done(ParseConfig config, ParseException e) {
ConfigService.getInstance();
ConfigService.getInstance().setInstance(StarterApplication.this);
Example 11
public void onCreate() {
super.onCreate();
if (!BuildConfig.DEBUG) {
Fabric.with(this, new Crashlytics());
Example 12
private void initializeFabric(){
if (!Fabric.isInitialized()) {
final Fabric fabric = new Fabric.Builder(this)
.kits(new Crashlytics())
.debuggable(true)
Fabric.with(fabric);
Example 13
public void onCreate() {
super.onCreate();
JodaTimeAndroid.init(this);
buildComponentAndInject();
if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
Fabric.with(this, new Crashlytics());
Timber.plant(new CrashReportingTree());
Example 14
public void onCreate() {
super.onCreate();
sInstance =
SharedPreferences prefs = getPrefs();
selectTheme(prefs.getInt(SettingsFragment.KEY_THEME, Constants.Theme.LIGHT));
prefs.registerOnSharedPreferenceChangeListener(this);
boolean isDebuggable = (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
sHasCrashlytics = !isDebuggable && !TextUtils.equals(Build.DEVICE, &sdk&);
if (sHasCrashlytics) {
Fabric.with(this, new Crashlytics());
mPt = new PrettyTime();
mClient = new DefaultClient();
mClient.setOAuth2Token(getAuthToken());
mServices = new HashMap&&();
mServices.put(STAR_SERVICE, new StarService(mClient));
mServices.put(WATCHER_SERVICE, new WatcherService(mClient));
mServices.put(LABEL_SERVICE, new LabelService(mClient));
mServices.put(ISSUE_SERVICE, new IssueService(mClient));
mServices.put(COMMIT_SERVICE, new CommitService(mClient));
mServices.put(REPO_SERVICE, new RepositoryService(mClient));
mServices.put(USER_SERVICE, new UserService(mClient));
mServices.put(MILESTONE_SERVICE, new MilestoneService(mClient));
mServices.put(COLLAB_SERVICE, new CollaboratorService(mClient));
mServices.put(DOWNLOAD_SERVICE, new DownloadService(mClient));
mServices.put(CONTENTS_SERVICE, new ContentsService(mClient));
mServices.put(GIST_SERVICE, new GistService(mClient));
mServices.put(ORG_SERVICE, new OrganizationService(mClient));
mServices.put(PULL_SERVICE, new PullRequestService(mClient));
mServices.put(EVENT_SERVICE, new EventService(mClient));
mServices.put(MARKDOWN_SERVICE, new MarkdownService(mClient));
Example 15
public void onCreate() {
super.onCreate();
if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
Fabric.with(this, new Crashlytics());
Timber.plant(new CrashReportingTree());
buildComponentAndInject();
Example 16
public void onCreate() {
super.onCreate();
Crashlytics crashlytics = new Crashlytics.Builder().disabled(isAnalyticsDisabled()).build();
Fabric.with(this, crashlytics);
GoogleAnalytics analytics = GoogleAnalytics.getInstance(getApplicationContext());
analytics.setAppOptOut(isAnalyticsDisabled());
analytics.setDryRun(isAnalyticsDisabled());
AnalyticsTracker.INSTANCE.inject(analytics.newTracker(R.xml.zen_tracker));
Example 17
public static void onError(Context context, String tag, Exception error) {
Log.e(tag, &Error&, error);
if (BuildConfig.DEBUG) {
if (context != null) {
Toast.makeText(context, &Error: & + tag + &\n& + error, Toast.LENGTH_SHORT).show();
if (error != null && error.getMessage() != null && Fabric.isInitialized()) {
Crashlytics.logException(error);
Example 18
public void onCreate() {
super.onCreate();
// logging setup
if (BuildConfig.DEBUG) {
// detailed logcat logging
Timber.plant(new Timber.DebugTree());
// crash and error reporting
Timber.plant(new AnalyticsTree(this));
if (!Fabric.isInitialized()) {
Fabric.with(this, new Crashlytics());
// initialize joda-time-android
JodaTimeAndroid.init(this);
// Load the current theme into a global variable
ThemeUtils.updateTheme(DisplaySettings.getThemeIndex(this));
// Ensure GA opt-out
GoogleAnalytics.getInstance(this).setAppOptOut(AppSettings.isGaAppOptOut(this));
if (BuildConfig.DEBUG) {
GoogleAnalytics.getInstance(this).setDryRun(true);
GoogleAnalytics.getInstance(this).getLogger().setLogLevel(Logger.LogLevel.VERBOSE);
// Initialize tracker
Analytics.getTracker(this);
// Enable StrictMode
enableStrictMode();
Example 19
protected void onCreate(Bundle savedInstanceState, int layoutId) {
super.onCreate(savedInstanceState, layoutId);
if(Fabric.isInitialized())
CrashlyticsCore.getInstance().log(getClass().getName() + & onCreate&);
if(!VersionUtils.isUsingCorrectBuild()) {
new AlertDialog.Builder(this)
.setMessage(pct.droid.base.R.string.wrong_abi)
.setCancelable(false)
PopcornUpdater.getInstance(this, new PopcornUpdater.Listener() {
public void updateAvailable(String updateFile) {
Intent installIntent = new Intent(Intent.ACTION_VIEW);
installIntent.setDataAndType(Uri.parse(&file://& + updateFile), PopcornUpdater.ANDROID_PACKAGE);
installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(installIntent);
}).checkUpdatesManually();
Example 20
public static void logException(Exception e) {
if (LOG) {
//noinspection CallToPrintStackTrace
e.printStackTrace();
if (Fabric.isInitialized())
Crashlytics.logException(e);
Example 21
private boolean setupCrashLytics(Context ctx)
Boolean setupD
if (!Fabric.isInitialized()) {
final Fabric fabric = new Fabric.Builder(ctx)
.kits(new Crashlytics())
.debuggable(true)
Fabric.with(fabric);
setupDone =
return setupD
Example 22
protected ThingResponse getThingResponse(BggService service, List&String& gameIds) {
int retries = 0;
while (true) {
String ids = TextUtils.join(&,&, gameIds);
if (Fabric.isInitialized()) {
Crashlytics.setString(&GAME_IDS&, ids);
return service.thing(ids, 1);
} catch (Exception e) {
if (e.getCause() instanceof SocketTimeoutException) {
if (mGamesPerFetch == 1) {
Timber.i(&...timeout with only 1 aborting.&);
mGamesPerFetch = mGamesPerFetch / 2;
Timber.i(&...timeout - reducing games per fetch to & + mGamesPerFetch);
} else if (e.getCause() instanceof RetryableException) {
retries++;
if (retries & MAX_RETRIES) {
Timber.i(&...retrying #& + retries);
Thread.sleep(retries * retries * RETRY_BACKOFF_IN_MS);
} catch (InterruptedException e1) {
Timber.i(&Interrupted while sleeping before retry & + retries);
return new ThingResponse();
Example 23
@Override public void onCreate() {
super.onCreate();
// Initialize the Parse SDK.
Parse.initialize(this, BuildConfig.PARSE_APP_ID, BuildConfig.PARSE_CLIENT_KEY);
// Register for Push Notifications ?
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
boolean notificationsEnabled =
sharedPref.getBoolean(SettingsFragment.PREF_KEY_ENABLE_NOTIFICATIONS, true);
if(notificationsEnabled){
ParsePush.subscribeInBackground(&&, new SaveCallback() {
public void done(ParseException e) {
if (e == null) {
Timber.d(&successfully subscribed to the broadcast channel.&);
Timber.e(e, &failed to subscribe for push&);
if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
Timber.plant(new CrashReportingTree());
if (!Fabric.isInitialized()) {
Fabric.with(this, new Crashlytics());
Example 24
* @see android.app.Application#onCreate()
public void onCreate() {
super.onCreate();
appContext = createAppContext();
LoggerUtils.setEnabled(appContext.isLoggingEnabled());
LOGGER = LoggerUtils.getLogger(AbstractApplication.class);
LOGGER.debug(&Executing onCreate on & + this);
List&Kit& fabricKits = Lists.newArrayList();
initAppModule(appModulesMap);
for (AppModule each: appModulesMap.values()) {
each.onCreate();
fabricKits.addAll(each.getFabricKits());
fabricKits.addAll(getFabricKits());
if (!fabricKits.isEmpty()) {
Fabric.with(this, fabricKits.toArray(new Kit[0]));
analyticsSender = createAnalyticsSender(createAnalyticsTrackers());
uriMapper = createUriMapper();
updateManager = createUpdateManager();
initExceptionHandlers();
LoggerUtils.setExceptionLogger(getExceptionHandler());
initStrictMode();
// This is required to initialize the statics fields of the utils classes.
ToastUtils.init();
DateUtils.init();
imageLoaderHelper = createImageLoaderHelper();
ExecutorUtils.execute(new Runnable() {
public void run() {
verifyAppLaunchStatus();
initDeviceYearClass();
if (getCacheManager() != null) {
getCacheManager().initFileSystemCache();
if (imageLoaderHelper != null) {
imageLoaderHelper.init();
appContext.saveFirstSessionTimestamp();
initRepositories();

我要回帖

更多关于 企业邮箱网页版登陆 的文章

 

随机推荐